flutter navigation doc code example
Example 1: navigation flutter
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
Example 2: flutter navigation
// inside MaterialApp in main.dart
routes: {
'<route_name>': (context) => MySecondscreen(),
},
// where you want to execute the code
Navigator.pushNamed(context, '<route_name>');