Add routers
To add routers go to the folder lib/src/routes/
. This folder has a file index.dart
that has routes definitions as shown below:
Route routes(RouteSettings settings) {
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => SplashScreen());
case '/home':
return MaterialPageRoute(builder: (_) => HomeScreen());
case '/auth':
return MaterialPageRoute(builder: (_) => AuthenticationScreen());
default:
return MaterialPageRoute(builder: (_) => SplashScreen());
}
}
To add a route, add a path name to this file and return your screen name class inside the MaterialPageRoute widget.
To push from one screen to another, use the following:
Navigator.pushNamed(context, '/home');