How to navigate without context in flutter app?

后端 未结 2 2072
一生所求
一生所求 2020-12-06 04:56

I have an app that recieves push notification using OneSignal. I have made a notification opened handler that should open specific screen on click of the notification. How c

2条回答
  •  粉色の甜心
    2020-12-06 05:20

    Look at this here: https://github.com/brianegan/flutter_redux/issues/5#issuecomment-361215074

    You can set a global key for your navigation:

    final GlobalKey navigatorKey = new GlobalKey();
    

    Pass it to MaterialApp:

    new MaterialApp(
          title: 'MyApp',
          onGenerateRoute: generateRoute,
          navigatorKey: navigatorKey,
        );
    

    Push routes:

    navigatorKey.currentState.pushNamed('/someRoute');
    

提交回复
热议问题