41 lines
971 B
Dart
41 lines
971 B
Dart
import 'package:bistro/login.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../life.dart';
|
|
|
|
class RouterTable {
|
|
// static String splashPath = 'splash';
|
|
static String loginPath = 'login';
|
|
static String homePath = '/';
|
|
|
|
// static String notFoundPath = '404';
|
|
|
|
static Map<String, WidgetBuilder> routeTables = {
|
|
//404页面
|
|
// notFoundPath: (context) => NotFound(),
|
|
//启动页
|
|
// splashPath: (context) => Splash(),
|
|
//登录
|
|
loginPath: (context) => const Login(),
|
|
//首页
|
|
homePath: (context) => const Life(),
|
|
};
|
|
|
|
///路由拦截
|
|
static Route onGenerateRoute<T extends Object>(RouteSettings settings) {
|
|
return MaterialPageRoute<T>(
|
|
settings: settings,
|
|
builder: (context) {
|
|
String name = settings.name!;
|
|
// if (routeTables[name] == null) {
|
|
// name = notFoundPath;
|
|
// }
|
|
|
|
Widget widget = routeTables[name]!(context);
|
|
|
|
return widget;
|
|
},
|
|
);
|
|
}
|
|
}
|