可能之前已经有人问过了,但我找不到答案,那么如何将参数传递给路由名称呢?
这是我构建路由的方式
Widget build(BuildContext context) {
return new Navigator(
initialRoute: 'home/chooseroom',
onGenerateRoute: (RouteSettings settings) {
WidgetBuilder builder;
switch (settings.name) {
case 'home/chooseroom':
// navigates to 'signup/choose_credentials'.
builder = (BuildContext _) => new ChoosePage();
break;
case 'home/createpage':
builder = (BuildContext _) => new CreateRoomPage();
break;
case 'home/presentation':
builder = (BuildContext _) => new Presentation();
break;
default:
throw new Exception('Invalid route: ${settings.name}');
}
return new MaterialPageRoute(builder: builder, settings: settings);
},
);
这是如何调用它的方法:Navigator.of(context).pushNamed('home/presentation')
但如果我的widget是new Presentation(arg1, arg2, arg3)
怎么办?