Hommie
Search…
Adding Screens

Creating Screen Files

Adding a new screen can be done in a couple of steps
  • Create a new folder, say new_screen and place it under /lib/views/ .
  • Create a new file new_screen.dart within this folder.
1
class NewScreen extends StatelessWidget {
2
. . .
3
. . .
4
}
Copied!

Updating Route

  • Open the file /lib/router.dart
  • importnewly created Screen into the Router
1
import 'package:appname/views/new_screen/new_screen.dart';
2
​
3
const String newScreen = 'new_screen';
4
​
5
Route<dynamic> generateRoute(RouteSettings settings) {
6
switch (settings.name) {
7
case newScreen:
8
return MaterialPageRoute(builder: (_) => NewScreen());
9
}
10
​
Copied!