我有这个对话框,我有一个问题:
当我点击关闭按钮时,它会产生我不想要的连锁反应。我只想让对话框按下。这是代码
// Child 3 : Close Button
Padding(
padding: EdgeInsets.fromLTRB(width * .62, height * .153, 0, 0),
child: RaisedButton(
splashColor: Colors.white,
hoverColor: Colors.blue,
elevation: 0,
onPressed: () {
setState(() {
Navigator.of(context).pop();
});
},
child: const Icon(
Icons.close,
color: Colors.black,
),
color: Colors.transparent,
),
),
——比;https://i.stack.imgur.com/tHqWX.jpg
你可以使用不提供额外ui装饰的GestureDetector
GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: const Icon(
Icons.close,
color: Colors.black,
),
),
也可以使用ElevatedButton
代替RaisedButton
,当它被弃用。
ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
overlayColor: MaterialStateProperty.all(Colors.green),
backgroundColor: MaterialStateProperty.all(Colors.transparent),
),
onPressed: () {},
child: const Icon(
Icons.close,
color: Colors.black,
),
),
关于GestureDetector
和ElevatedButton
的更多信息。