dartflutterflutter-layoutdart-2

Could not find a generator for route "home-page" in the _MaterialAppState


I am getting exception when I trying to navigate from one view to another in flutter app.

I/flutter ( 2199): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 2199): The following assertion was thrown while handling a gesture:
I/flutter ( 2199): Could not find a generator for route "home-page" in the _MaterialAppState.

Solution

  • Use

    Navigator.push(context, new MaterialPageRoute(
      builder: (context) =>
         new MyHomePage())
      );
    

    Instead of

    Navigator.of(context).pushNamed('/home-page');
    //or
    Navigator.pushedName(context, '/home-page');