我已经尝试了几天来从通知路由,我检查了根窗口小部件,并还在导航器中使用了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');
}
});