颤抖,添加PageRouteBuilder

时间:2018-07-04 12:50:06

标签: flutter flutter-animation

我正在尝试修改导航转换代码以使用PageRouteBuilder。请参见方法_gotoThirdPage()。
问题是我无法将参数传递给新页面。例如,我在传递标题时崩溃。还寻找发送多个参数的示例,例如地图。 请求:有人可以修改_gotoThirdPage()方法以将参数发送到Class SecondPage类。 // ====================。下面的代码===================

PySide4

1 个答案:

答案 0 :(得分:0)

我不太确定您要做什么。对我来说,将参数传递给新页面的最简单方法是使用新页面的构造函数,如果我需要进行一些处理,请稍后显示/使用/传递它们。尽管我认为如果您有大量参数,这是不合适的。

因此,在某些情况下,我会使用SharedPrefences。我认为这对于发送多个参数(例如地图)会更好。

关于导航的所有问题,我建议您对命名的路线使用“导航”。像这样:

MaterialApp(
  // Start the app with the "/" named route. In our case, the app will start
  // on the FirstScreen Widget
  initialRoute: '/',
  routes: {
    // When we navigate to the "/" route, build the FirstScreen Widget
    '/': (context) => FirstScreen(),
    // When we navigate to the "/second" route, build the SecondScreen Widget
    '/second': (context) => SecondScreen(),
  },
);

然后:

Navigator.pushNamed(context, '/second');

Documentation

相关问题