如何处理Flutter中的上一页?
如果我做了Navigator.push
,如何在第二页关闭时执行一些动作?
答案 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
}