flutter routes code example
Example 1: flutter navigate to new screen
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
}
Example 2: named routes flutter
MaterialApp(
routes: {
'/':(context)=>HomePage(),
'/meals':(context)=>MealsPage(),
'/orders':(context)=>Orders(),
},
);
Example 3: routes in flutter
routes in flutter
Example 4: routes in flutter
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
Example 5: material app routes
MaterialApp(
initialRoute: '/',
routes: {
'/': (context) => FirstScreen(),
'/second': (context) => SecondScreen(),
},
);
Example 6: page routing flutter
Page Navigation in flutter