【问题标题】:How do I handle returning to the previous page in Flutter?在 Flutter 中如何处理返回上一页?
【发布时间】:2019-11-02 19:38:28
【问题描述】:

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

【问题讨论】:

    标签: flutter dart flutter-navigation


    【解决方案1】:

    您“等待”页面“弹出”

    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
      }
    

    【讨论】:

      猜你喜欢
      • 2018-09-24
      • 1970-01-01
      • 2022-07-25
      • 2022-01-19
      • 2016-05-28
      • 2022-01-08
      • 2019-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多