title: Flutter : Could not find a generator for route RouteSettings("/HomePage", null) in the _WidgetsAppState
body: <p>I'm using the following in my demo project for routes:</p>
  <pre><code> routes: &lt;String, WidgetBuilder&gt;{
      '/HomePage': (BuildContext context) =&gt; HomePage()
    },
  </code></pre>
  <p>And trying to navigate home screen using the following code:</p>
  <pre><code>onPressed: () {
      debugPrint(&quot;Hello button is clicked&quot;);
  
       Navigator.of(context)
                 .pushReplacementNamed('/HomePage');
   },
  </code></pre>
  <p>But When my button clicked I'm getting the following Exception:</p>
  <pre><code>════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════
  The following assertion was thrown while handling a gesture:
  Could not find a generator for route RouteSettings(&quot;/HomePage&quot;, null) in the _WidgetsAppState.
  
  Generators for routes are searched for in the following order:
   1. For the &quot;/&quot; route, the &quot;home&quot; property, if non-null, is used.
   2. Otherwise, the &quot;routes&quot; table is used, if it has an entry for the route.
   3. Otherwise, onGenerateRoute is called. It should return a non-null value for any valid route not handled by &quot;home&quot; and &quot;routes&quot;.
   4. Finally if all else fails onUnknownRoute is called.
  Unfortunately, onUnknownRoute was not set.
  When the exception was thrown, this was the stack: 
  #0      _WidgetsAppState._onUnknownRoute.&lt;anonymous closure&gt; (package:flutter/src/widgets/app.dart:772:9)
  #1      _WidgetsAppState._onUnknownRoute (package:flutter/src/widgets/app.dart:785:6)
  #2      NavigatorState._routeNamed (package:flutter/src/widgets/navigator.dart:1625:22)
  #3      NavigatorState.pushReplacementNamed (package:flutter/src/widgets/navigator.dart:1690:35)
  #4      _RegisterPage.build.&lt;anonymous closure&gt; (package:oricon/register.dart:231:42)
  </code></pre>
  <blockquote>
  <p>I have already checked below Stack-overflow links</p>
  </blockquote>
  <ul>
  <li><a href="https://stackoverflow.com/q/58909129/8112541">Could not find a generator for route RouteSettings(&quot;/&quot;, null) in the _WidgetsAppState</a></li>
  <li><a href="https://stackoverflow.com/q/56233077/8112541">How to use routes in flutter to navigate to page other than from main?</a></li>
  <li><a href="https://stackoverflow.com/q/52405521/8112541">Could not find a generator for route &quot;home-page&quot; in the _MaterialAppState</a></li>
  <li><a href="https://stackoverflow.com/q/57146482/8112541">Why does it not work when I use pushNamedReplacement instead of pushReplacement?</a></li>
  </ul>
  <p>If you need more information, please do let me know.</p>