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
flutter clean
and run again, is working for me.
I have encountered the same error and solved by just restarting the app
@aziza is the right answer but in some miscellaneous situation in my case
class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case '/':
MaterialPageRoute(builder: (_) => MyScaffold());
break;
case '/homechart':
MaterialPageRoute(builder: (_) => analytics());
break;
}
}
}
I forget to return keyword and IDE not showing any error. showing this kind of error.
Solution is like this :
class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => MyScaffold());
break;
case '/homechart':
return MaterialPageRoute(builder: (_) => analytics());
break;
}
}
}
In my case the error was because i deleted the route
from main.dart
and forgot the update the change in other files
You have instantiated two MaterialApp widget. You need to remove the one in MyApp class.
For push
Navigator.of(context).pushNamed('/screen1')
For Pop: "popAndPushNamed"
Navigator.of(context).popAndPushNamed('/screen4');
try this :
onPressed: () {
Navigator.push(
context,
new MaterialPageRoute(
builder: (context) => new ListaDeCompras(),
),
);
},