【发布时间】:2020-05-13 02:51:28
【问题描述】:
我有一个这样的routing:
routes: {
'/': (context) => MainPage(),
'/othe_page': (context) => OthePage(),
},
Navigator.pushNamed(context, '/othe_page');
如何将 bloc 传递给 OthePage 小部件?
【问题讨论】:
-
如果你想将参数传递给 OthePage(),你可以在 pushNamed 方法中添加一个命名参数。 Navigator.pushNamed(context, routeName, arguments: );
-
将 bloc 作为参数传递好吗? @FederickJonathan
-
如果你使用 Flutter_Bloc 包,最好使用 BlocProvider.of(context) 而不是传递 bloc 本身
标签: flutter flutter-bloc