Skip to content

Instantly share code, notes, and snippets.

@md-weber
Created August 25, 2019 01:38
Show Gist options
  • Save md-weber/423e0de8f12bb7ab8f139cb65785eba7 to your computer and use it in GitHub Desktop.
Save md-weber/423e0de8f12bb7ab8f139cb65785eba7 to your computer and use it in GitHub Desktop.
Router of my Flutter App
import 'package:client/paths.dart';
import 'package:client/ui/pages/home.page.dart';
import 'package:client/ui/pages/login.page.dart';
import 'package:client/ui/pages/register.page.dart';
import 'package:flutter_web/material.dart';
class Router {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case RoutePaths.Home:
return MaterialPageRoute(builder: (_) => MyHomePage());
case RoutePaths.Login:
return MaterialPageRoute(builder: (_) => LoginPage());
case RoutePaths.Register:
return MaterialPageRoute(builder: (_) => RegisterPage());
default:
return MaterialPageRoute(
builder: (_) => Scaffold(
body: Center(
child: Text("No route found for this scenario"),
),
),
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment