title: How to redirect to a page in flutter from push notification
body: <p>I am implementing push notification in my flutter app and need some help on how to redirect..</p>
  
  <p>Basically,this is normal flow</p>
  
  <p><strong>app-> root->home->list->detail</strong>. There is a default back navigation </p>
  
  <p>When a user get a push notification and click on it then they go directly to the detail page. This is correct but I want to see a back button where they can go to the home screen. </p>
  
  <p><strong>app->detail</strong></p>
  
  <p>What I want is after user view the detail then they should go back to the home screen . However, there no back button in this scenario</p>
  
  <p>this is my root page</p>
  
  <pre><code>class RootPage extends StatefulWidget {
  
    RootPage({Key key}) : super(key: key);
    _RootPage createState() =&gt; _RootPage();
  }
  class _RootPage extends State&lt;RootPage&gt; with WidgetsBindingObserver {
    AppLifecycleState _appLifecycleState;
    var _message;
    @override
    void didChangeAppLifecycleState(AppLifecycleState state) {
      setState(() {
        _appLifecycleState = state;
      });
    }
    final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
    @override
    void initState() {
      super.initState();
      WidgetsBinding.instance.addObserver(this);
      _firebaseMessaging.configure(
        onMessage: (Map&lt;String, dynamic&gt; message) {
          setState(() {
            _message = message;
          });
        },
        //app in background
        onResume: (Map&lt;String, dynamic&gt; message) {
          setState(() {
            _message = message;
          });
        },
      );
      _firebaseMessaging.requestNotificationPermissions(
          const IosNotificationSettings(sound: true, badge: true, alert: true));
    }
    @override
    void dispose() {
      WidgetsBinding.instance.removeObserver(this);
      super.dispose();
    }
    @override
    Widget build(BuildContext context) {
  
      if (_message != null) {
        if (_appLifecycleState != null &amp;&amp; _appLifecycleState.index == 0) {
          // app is in resume state
          if (_message["type"] == "Notification") {
            String _Id = _message["Id"];
            String _reference = _message["reference"];
            return (DetailPage(Id: _Id, reference: _reference));
          }
        }
      } //end if
      return MyHomePage();
    }
  }
  </code></pre>
  
  <hr>
  
  <p>HOME PAGE</p>
  
  <pre><code>class MyHomePage extends StatefulWidget {
  
    MyHomePage({Key key, this.title}) : super(key: key);
    final String title;
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
    @override
    void initState() {
      super.initState();
  
    }
    final List&lt;Widget&gt; _children = [
      List(),
      Search(),
      MyCalendarPage(),
    ];
    var _currentIndex = 0;
    @override
    Widget build(BuildContext context) {
      return  Scaffold(
            appBar: AppBar(
              title: Center(child: Text("my app")),
              actions: &lt;Widget&gt;[
                new IconButton(
                  icon: new Icon(Icons.favorite),
                  onPressed: () {},
                ),
  
              ],
            ),
            drawer: Drawer(),
            body: _children[_currentIndex],
            bottomNavigationBar: BottomNavigationBar(
                type: BottomNavigationBarType.fixed,
                onTap: onTabTapped, // new
                currentIndex: _currentIndex, // new
                items: [
                  new BottomNavigationBarItem(
                    icon: new Icon(Icons.home),
                    title: new Text("home"),
                  ),
                  new BottomNavigationBarItem(
                    icon: new Icon(Icons.search),
                    title: new Text("search"),
                  ),
                  new BottomNavigationBarItem(
                    icon: new Icon(Icons.schedule),
                    title: new Text("schedule"),
                  )
                ]
                )
                );
    }
  
    void onTabTapped(int index) {
      setState(() {
        _currentIndex = index;
      });
    }
  }
  </code></pre>
  
  <p>How can I go to the home screen then redirect to the detail page if there push notification? I believe then I would see a back button since the previous page would have been the home screen..</p>
  
  <p>Not sure how to re-work my code to make this happen</p>
  
  <p>Thanks for the help</p>