【发布时间】:2019-02-10 16:47:57
【问题描述】:
是否可以通过单击通知导航到应用程序中的特定 MaterialPageRoute?我在主屏幕中配置了通知:
void _configureNotifications() {
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
_firebaseMessaging.requestNotificationPermissions();
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) {
_goToDeeplyNestedView();
},
onLaunch: (Map<String, dynamic> message) {
_goToDeeplyNestedView();
},
onResume: (Map<String, dynamic> message) {
_goToDeeplyNestedView();
},
);
}
_goToDeeplyNestedView() {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => DeeplyNestedView()));
}
问题是,当我这样配置它时,它只能从我配置通知的小部件中工作(我猜这是因为在 导航器.push()。是否有某种方法可以在不使用任何上下文的情况下从应用程序中的任何位置访问 MaterialPageRoute?
提前感谢您的回答。
【问题讨论】: