Reputation: 25
it is showing this error
Could not find a generator for route in the _WidgetsAppState.
How can I navigate if my app has two MaterialApp
widgets?
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: Colors.brown,
accentColor: Colors.blue,
),
debugShowCheckedModeBanner: false,
home: SplashScreen(),
routes: <String, WidgetBuilder>{
'/HomeScreen': (BuildContext context) => new HomeScreen(),
},
);
}
}
Upvotes: 0
Views: 3282
Reputation: 867
Can you provide more code showing how you triggering that route? Seems like you're using the first screen as a splash screen. If you navigate to HomeScreen()
when some button is pressed then try using MaterialPageRoute()
without using routes.
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => new HomeScreen()))
Upvotes: 1
Reputation: 4648
It would be better if you provided some code but you can use GlobalKey.
Upvotes: 0