Could not find a generator for route

后端 未结 8 1377
谎友^
谎友^ 2021-01-07 17:03

I´m newbie to flutter and reveice one exception about route and paginator in Flutter.

EXCEPTION CAUGHT BY GESTURE
The following assertion was thrown while ha         


        
相关标签:
8条回答
  • 2021-01-07 17:36

    This is because you have instantiated two MaterialApp widgets. You need to remove the one in MyApp class and may change it to Scaffold instead like this:

    class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
    return new Scaffold(
    // ...                    
                    return new ListTile(
                      onTap: () {                                         
                        Navigator.pushNamed(context, "/listadecompras");
                      },
    // ...
    }
    

    What happened in your code is the route is trying to resolve for the nearest MaterialApp which has no route definition. That said you should use only one MaterialApp as the root of your widget tree.

    0 讨论(0)
  • 2021-01-07 17:37

    If a new file is created and you are defining a route for that new file, its better to re-run the app rather than hot reloading.It worked for me!

    0 讨论(0)
提交回复
热议问题