【发布时间】:2021-01-24 19:29:11
【问题描述】:
标准图标按钮不会对孩子产生任何连锁反应:
IconButton(
icon: Container(color: Colors.red,),
onPressed: () {},
)
所以我尝试用 Stack 修复它:
class MyIconButton extends StatelessWidget {
const MyIconButton({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
height: 100,
width: 100,
child: Stack(
fit: StackFit.loose,
children: [
Positioned.fill(
child: Container(
width: 40,
height: 40,
color: Colors.deepPurple,
),
),
Positioned.fill(
child: Material(
type: MaterialType.transparency,
shape: const CircleBorder(),
child: IconButton(
splashRadius: 50,
icon: Container(),
onPressed: () {
},
),
),
)
],
),
);
}
}
但是这个小部件需要定义容器的大小,并且当我定义该大小时,我无法在该容器之外显示涟漪效应。我愿意接受建议。
【问题讨论】: