如何在扑扑的路线页面之间发送数据? [英] How to send data between route pages in flutter?

查看:48
本文介绍了如何在扑扑的路线页面之间发送数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有两个页面,即时通讯使用它来导航到另一页面

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 Routes 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆