void selectNotification(String? payload) async {
print('Selected notification');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SearchScreen(),
),
);
}
当点击通知时,我使用这种方法打开屏幕,我得到了打印消息,但随后导航器消息显示:
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
我只是想拥有它,所以如果从前台、后台点击通知,应用程序就会弹出屏幕,但我无法让它正常工作
void selectNotification(String? payload, BuildContext context) async {
print('Selected notification');
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SearchScreen(),
),
);
}
使用getX包并使用导航路由:像这样的东西:Get.put(()=> **your page**
getX包