我想在SnackBar终止后弹出屏幕。
怎么办?
Scaffold.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.pink,
content: Text('Successfull !'),
duration: Duration(seconds: 5),
),
);
Navigator.of(context).pop();
答案 0 :(得分:2)
使用closed
then
Scaffold.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.pink,
content: Text('Successfull !'),
duration: Duration(seconds: 5),
),
).closed.then((SnackBarClosedReason reason) {
Navigator.of(context).pop();
});