如何在扑扑的路线页面之间发送数据? [英] How to send data between route pages in flutter?
问题描述
所以我有两个页面,即时通讯使用它来导航到另一页面
So i have two page, and im using this to navigate to the other page
Navigator.of(context).pushNamed('page-2');
如何从第1页传递数据对象并将其发送到第2页?
how do i pass the data object from page 1 and sent to page 2?
推荐答案
这是一个话题,正如@Linus Juhlin提到的那样,实际上,上个礼拜又在
This is a topic that's still being discussed as @Linus Juhlin mentioned, actually it came up again last week in the flutter google group
您实际上可以使用 MaterialApp
中的> onGenerateRoute 属性来自己构建 Route
,如在推路线时.
You can actually use the onGenerateRoute
property from MaterialApp
to build the Route
s yourself as shown in the stocks demo app. This gets a bit tricky because you'll have to pass in a string representation of the data you need to pass to the next page when pushing the route.
您还可以使用名为 Fluro 的库,该库会隐藏一些样板代码,您只需定义处理程序函数即可处理每条路线.
You can also use a library called Fluro which hides some of that boilerplate code and you just have to define handler functions to handle each route.
这篇关于如何在扑扑的路线页面之间发送数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!