gpt4 book ai didi

flutter - Flutter在导航弹出后获得引用

转载 作者:行者123 更新时间:2023-12-03 04:35:19 24 4
gpt4 key购买 nike

我想引用要显示的屏幕。
使用此代码:

Navigator.of(context).pop()
我实际上回到了上一个屏幕,但是我想访问该引用文献来做一些工作。
我怎样才能做到这一点?
在Swift中使用iOS背景时,我会做类似的事情:
var newScreen = Navigator.of(context).pop();

最佳答案

您无法创建引用,因为当您弹出当前“路线”时,所有数据都会被处理掉。
但是,您可以按照官方pop result的说明将docs返回给等待的父级。
就像是:

//When you will dispose the pushed page/route you can pass your result to pop method
Navigator.pop(context, 'This is my new page result');

//In the parent page you will await for the result
final result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyPushedPage()),
);
print(result) //--> This is my new page result

关于flutter - Flutter在导航弹出后获得引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64207335/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com