How to show snackbar after navigator.pop(context)

2020-02-06 06:03发布

We need close one screen and open second screen. And show snackbar on second screen from first screen.

I tried to use Navigator.push , but this screen is already open and we have this error "Bad state: Stream has already been listened to".

2条回答
家丑人穷心不美
2楼-- · 2020-02-06 06:20

Instead of Snackbar i would suggest you to use Flushbar plugin for flutter it is easy to use and it'll take care of everything and u can customize it to a great extent . Snackbar needs a scaffold ancestor to work but Flushbar doesn't and it takes care of all the extra stuff itself and provides with ton of cool features.

Flushbar Plugin here

查看更多
虎瘦雄心在
3楼-- · 2020-02-06 06:29
showSubmitRequestSnackBar(BuildContext context) async {

  Flushbar(
    flushbarPosition: FlushbarPosition.BOTTOM,
    message: "Request Successfully Saved",
    icon: Icon(
      Icons.info_outline,
      size: 28.0,
      color: Colors.red,
    ),
    backgroundColor: Colors.red,
    duration: Duration(seconds: 5),
    leftBarIndicatorColor: Colors.red,

  )
    ..show(context).then((r)=> Navigator.push(
        context, MaterialPageRoute(builder: (context) => ListPage(""))));
}
查看更多
登录 后发表回答