您可以在新路由时注册回调,push该路由也可以包含弹出路由中的数据(例如,如果您需要从中传递数据)。
Navigator.of(context).push(/*Some route*/).then((data) {
// You can call your function here. data will be null if nothing is passed from the popped route
});
Run Code Online (Sandbox Code Playgroud)
如果你想从弹出的路线通过data,就这样做
Navigator.of(context).pop(someData);
Run Code Online (Sandbox Code Playgroud)
如果您想知道转换何时真正结束,您也可以为其注册一个回调侦听器
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => RouteWidget())
..completed.then((_) {print('transition completed');},
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3258 次 |
| 最近记录: |