初始化项目
This commit is contained in:
47
lib/routers/routers.dart
Normal file
47
lib/routers/routers.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/device_type.dart';
|
||||
import 'package:vbvs_app/pages/login/login.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/e_page.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/home_page.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/main_page_bottom_change.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/message_page.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/mine_page.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/sleep_report_page.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
var routes = {
|
||||
"/homePage": (contxt) => HomePage(),
|
||||
"/sleepReportPage": (contxt) => SleepReportPage(),
|
||||
"/ePage": (contxt) => EPage(),
|
||||
"/messagePage": (contxt) => MessagePage(),
|
||||
"/minePage": (contxt) => MinePage(),
|
||||
"/mianPageBottomChange": (contxt) => MainPageBottomChange(),
|
||||
"/loginPage": (contxt) => LoginPage(),
|
||||
"/deviceType": (contxt) => DeviceTypePage(),
|
||||
};
|
||||
|
||||
//2、配置onGenerateRoute 固定写法 这个方法也相当于一个中间件,这里可以做权限判断
|
||||
var onGenerateRoute = (RouteSettings settings) {
|
||||
final String? name = settings.name; // /news 或者 /search
|
||||
final Function? pageContentBuilder =
|
||||
routes[name]; // Function = (contxt) { return const NewsPage()}
|
||||
|
||||
if (pageContentBuilder != null) {
|
||||
if (settings.arguments != null) {
|
||||
final Route route = CupertinoPageRoute(
|
||||
settings: settings,
|
||||
builder: (context) =>
|
||||
pageContentBuilder(context, arguments: settings.arguments));
|
||||
return route;
|
||||
} else {
|
||||
final Route route = CupertinoPageRoute(
|
||||
settings: settings,
|
||||
builder: (context) => pageContentBuilder(context));
|
||||
|
||||
return route;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Reference in New Issue
Block a user