title: Flutter: How to avoid pushing the same route on existing route
body: <p>I have view with bottom navigation bar, and when you push a navbar item, a new route is pushed into view. </p>
  
  <pre><code> final navigatorKey = GlobalKey&lt;NavigatorState&gt;();
  
   @override
    Widget build(BuildContext context) =&gt; MaterialApp(
      home: Scaffold(
        key: _scaffoldKey,
        body: _buildBody(context),
        bottomNavigationBar: _buildBottomNavigationBar(context),
      ),
    );
  
   void routeToView(routeIndex) {
        navigatorKey.currentState.pushNamed(pagesRouteFactories.keys.toList()[routeIndex]);
    }
  </code></pre>
  
  <p>I would like to prevent same route being pushed on the current view. I want to compare the current route with new route we are trying to push, and ignore pushing the route if it is same. </p>
  
  <p>I want to scroll the view to the top if it is same route we are trying to push</p>
  
  <p>Any ideas.</p>