我建议您使用Stack小部件,因为您可以将多个小部件组合在一起。这里有一个容器的例子,其中包含内部容器,它们都可以独立点击。
Stack(
children: [
InkWell(
onTap: (){},
child: Container(
width: 400,
height: 400,
color: Colors.green,
),
),
Positioned(
top: 30,
left: 20,
child: InkWell(
onTap: (){},
child: Container(
width: 100,
height: 100,
color: Colors.red,
),
))
],
)
这对我有用
Center(
child:Container(
width: 100,
height: 100,
child: Card(
child: InkWell(
splashColor: color3,
onTap: () {
},
child: Column(
children: [
SizedBox(
height: 10,
),
IconButton(
splashRadius: 7,
splashColor: Colors.pink,
onPressed: () {},
icon: SvgPicture.asset(
ImageConst.bellIcon,
width: 20,
height: 20,
color: Colors.black,
),
),
SizedBox(
height: 10,
),
Text("text"),
],
),
),
),
),
)
InkWell
>Container
>Row
>[Text
,IconButton
] 的演示,墨水飞溅效果是单独处理的(即点击图标不会触发外部InkWell
的飞溅效果)。 也许在 Flutter 2 中已经修复了这个问题。你能提供源代码吗? - Crizant