import 'package:flutter/cupertino.dart'; import 'package:vbvs_app/pages/device_bind/bind_device_success.dart'; import 'package:vbvs_app/pages/device_bind/blueteeth_device_page.dart'; import 'package:vbvs_app/pages/device_bind/device_type.dart'; import 'package:vbvs_app/pages/device_bind/wifi_page.dart'; import 'package:vbvs_app/pages/login/login.dart'; import 'package:vbvs_app/pages/login/other_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'; import 'package:vbvs_app/pages/person/person_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(), "/blueteethDevice": (contxt) => BlueteethDevicePage(), "/personPage": (contxt) => PersonPage(), "/bindDeviceSuccess": (contxt) => BindDeviceSuccess(), // "/wifiPage": (contxt, {arguments}) => WifiPage(connectedDeviceProp: arguments), "/wifiPage": (contxt, {arguments}) => WifiPage(bluetoothDevice: arguments), "/otherLoginPage": (contxt) => OtherLoginPage(), }; //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; };