0

在 Flutter 中如何处理返回上一页?如果我这样做了,当第二页关闭时Navigator.push如何执行一些操作?

4

1 回答 1

0

您“等待”页面“弹出”

Future<void> pushScreenAndDoSomething(BuildContext context)async{
    await Navigator.of(context).pushNamed('YourPage');
    print('This executes after the screen is destroyed');

    //you can also get a result 
    String p = await Navigator.of(context).pushNamed('YourPage');
    //Inside your page, you Navigator.of(context).pop('DATA');
    print(p); //it should print DATA
  }
于 2019-11-02T19:42:46.957 回答