如何处理Flutter中的上一页?

时间:2019-11-02 19:38:28

标签: flutter dart flutter-navigation

如何处理Flutter中的上一页? 如果我做了Navigator.push,如何在第二页关闭时执行一些动作

1 个答案:

答案 0 :(得分: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
  }