Flutter异常:未处理的异常:在_WidgetsAppState中找不到路由RouteSettings(“ / Mas”,null)的生成器

时间:2020-11-11 14:59:17

标签: firebase flutter push-notification firebase-cloud-messaging

我已经尝试了几天来从通知路由,我检查了根窗口小部件,并还在导航器中使用了MaterialApp,但是我仍然遇到相同的例外,有关如何处理的任何建议?非常感谢:)

我的main.dart

runApp(MaterialApp(
home: MyApp(),
));

class _MyAppState extends State<MyApp> {
  FirebaseMessaging messaging = FirebaseMessaging.instance;
  FirebaseAnalytics analytics = FirebaseAnalytics();....

return MaterialApp(
  home: Builder(
    builder: (context) => HomePage(),
  ),
  initialRoute: '/',
  theme: ThemeData(accentColor: AppColors.VERDE_KDI),
  navigatorObservers: [FirebaseAnalyticsObserver(analytics: analytics)],
  routes: {
    '/Favoritos': (context) => Favoritos(),
    '/Buscar': (context) => Buscar(),
    '/Mas': (context) => Mas(),
  },
);

以及我的导航方式

FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
  if (message.data['view'] == 'Favoritos') {
    Navigator.pushNamed(context, '/Favoritos');
  } else if (message.data['view'] == 'Mas') {
    Navigator.pushNamed(context, '/Mas');
  } else if (message.data['view'] == 'Buscar') {
    Navigator.pushNamed(context, '/Buscar');
  }
});

0 个答案:

没有答案