InkWell在父容器設(shè)置了背景色后沒有點(diǎn)擊效果的原因主要是因?yàn)镮nkWell的點(diǎn)擊效果是通過Material組件實(shí)現(xiàn)的,而當(dāng)InkWell不在Material內(nèi)部時(shí)哮奇,其點(diǎn)擊效果無法正常顯示钩乍。
在InkWell的外層再套上Matetial 以及 Ink組件
Material(
child: Ink(
child:
InkWell(
onTap: () { },
child: Container(
height: 50.0,
color: Colors.white,
child: Text( "點(diǎn)擊",
maxLines: 1,
style: TextStyle(color: color),
overflow: TextOverflow.ellipsis,
),
),
),
),
)
InkWell 在父容器設(shè)置了背景色后,沒有點(diǎn)擊效果了导饲。
使用Ink包裹InkWell:可以在InkWell外層再包裹一個(gè)Ink組件讯嫂,并在Ink中設(shè)置顏色。
Ink(
color: Colors.white, // 設(shè)置背景色
child: InkWell(
onTap: () {// 點(diǎn)擊事件
},
child: Container(
color: Colors.white, // 設(shè)置背景色
child: Text('點(diǎn)擊?恢谩荣挨!'),
),
),
);