[英]How can I send data to an anonymous class in Flutter?
How do I send data back to a view when the view is anonymous (I am writing a library that takes a user from his present view to another, then return the users back to the initial view but also with a payload/data).当视图是匿名的时,如何将数据发送回视图(我正在编写一个库,将用户从当前视图带到另一个视图,然后将用户返回到初始视图,但还带有有效负载/数据)。 In my code I go back to the anonymous previous view using:在我的代码中,我使用 go 回到匿名的先前视图:
Navigator.pop(context);
but how do I send data (string or object) along with it?但是我如何发送数据(字符串或对象)? or does flutter have a message dispatcher that is received by all views who listen for it?或者 flutter 是否有一个消息调度程序,所有收听它的视图都会收到消息调度程序?
Use利用
Navigator.pop(context, data);
The caller needs to listen it using调用者需要使用
var data = await Navigator.push(...);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.