import 'dart:io'; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:huixiang/address/address_map_page.dart'; import 'package:huixiang/address/edit_address_page.dart'; import 'package:huixiang/article/hot_article_details_page.dart'; import 'package:huixiang/article/hot_article_item.dart'; import 'package:huixiang/article/video_playback_page.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/integral/integral_detailed_page.dart'; import 'package:huixiang/integral/integral_page.dart'; import 'package:huixiang/integral_store/integral_store_details_page.dart'; import 'package:huixiang/login/login_page.dart'; import 'package:huixiang/message/main_message_page.dart'; import 'package:huixiang/message/system_message.dart'; import 'package:huixiang/mine/edit_name.dart'; import 'package:huixiang/mine/mine_card_invalid_page.dart'; import 'package:huixiang/mine/mine_card_page.dart'; import 'package:huixiang/mine/mine_vip_level_page.dart'; import 'package:huixiang/mine/mine_wallet_page.dart'; import 'package:huixiang/mine/recharge_page.dart'; import 'package:huixiang/mine/user_info_page.dart'; import 'package:huixiang/order/exchange_history_page.dart'; import 'package:huixiang/order/exchange_order_page.dart'; import 'package:huixiang/order/exchange_order_success_page.dart'; import 'package:huixiang/order/exchange_order_detail_page.dart'; import 'package:huixiang/order/logistics_information_page.dart'; import 'package:huixiang/order/order_detail_page.dart'; import 'package:huixiang/order/order_history_page.dart'; import 'package:huixiang/order/store_selector_page.dart'; import 'package:huixiang/order/write_off_page.dart'; import 'package:huixiang/order/write_off_success_page.dart'; import 'package:huixiang/setting/about_page.dart'; import 'package:huixiang/setting/help_feedback_page.dart'; import 'package:huixiang/setting/permission_setting_page.dart'; import 'package:huixiang/setting/setting_page.dart'; import 'package:huixiang/union/store_details_page.dart'; import 'package:huixiang/union/union_details_page.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'main_page.dart'; import 'mine/manage_address_page.dart'; import 'mine/roll_center_page.dart'; void main() { if (Platform.isAndroid) { SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle(statusBarColor: Colors.transparent)); } runApp(MyApp()); } Map routers = { '/router/main_page': (context, {arguments}) => MainPage(), '/router/login': (context, {arguments}) => LoginPage(), '/router/msg_page': (context, {arguments}) => MainMessagePage(), '/router/system_msg_page': (context, {arguments}) => SystemMessagePage(), '/router/exchange_order_details': (context, {arguments}) => ExchangeOrderDetailPage(), '/router/integral_page': (context, {arguments}) => IntegralPage(), '/router/integral_detailed_page': (context, {arguments}) => IntegralDetailedPage(), '/router/mine_wallet': (context, {arguments}) => MineWalletPage(), '/router/user_info_page': (context, {arguments}) => UserInfoPage(), '/router/mine_card': (context, {arguments}) => MineCardPage(), '/router/mine_card_invalid': (context, {arguments}) => MineCardInvalidPage(), '/router/permission_setting': (context, {arguments}) => PermissionSettingPage(), '/router/manage_address_page': (context, {arguments}) => ManageAddressPage(arguments: arguments), '/router/setting_page': (context, {arguments}) => SettingPage(), '/router/about_page': (context, {arguments}) => AboutPage(), '/router/help_feedback_page': (context, {arguments}) => HelpFeedbackPage(), '/router/union_detail_page': (context, {arguments}) => UnionDetailsPage(arguments: arguments), '/router/store_detail_page': (context, {arguments}) => StoreDetailsPage(arguments:arguments), '/router/integral_store_page': (context, {arguments}) => IntegralStoreDetailsPage( arguments: arguments, ), '/router/exchange_order_page': (context, {arguments}) => ExchangeOrderPage( arguments: arguments, ), '/router/store_selector_page': (context, {arguments}) => StoreSelectorPage(), '/router/exchange_order_success_page': (context, {arguments}) => ExchangeOrderSuccessPage( arguments: arguments, ), '/router/mine_vip_level_page': (context, {arguments}) => MineVipLevelPage(), '/router/exchange_history_page': (context, {arguments}) => ExchangeHistoryPage(), '/router/write_off_page': (context, {arguments}) => WriteOffPage(), '/router/write_off_success_page': (context, {arguments}) => WriteOffSuccessPage(), '/router/order_history_page': (context, {arguments}) => OrderHistoryPage(), '/router/order_details': (context, {arguments}) => OrderDetailPage(), '/router/recharge_page': (context, {arguments}) => RechargePage(), '/router/hot_article_page': (context, {arguments}) => HotArticlePage(), '/router/address_edit_page': (context, {arguments}) => EditAddressPage( arguments: arguments, ), '/router/address_map_page': (context, {arguments}) => AddressMapPage(), '/router/logistics_information_page': (context, {arguments}) => LogisticsInformationPage(), '/router/hot_article_details_page': (context, {arguments}) => HotArticleDetailsPage(), '/router/video_playback_page': (context, {arguments}) => VideoPlaybackPage(), '/router/roll_center_page': (context, {arguments}) => RollCenterPage(), '/router/edit_name': (context, {arguments}) => EditName( arguments:arguments, ), // '/router/ui_test': (context, {arguments}) => UITest(), }; class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return ScreenUtilInit( designSize: Size(375, 812), builder: () => MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, textTheme: TextTheme( button: TextStyle(fontSize: 24.sp), bodyText1: TextStyle(fontSize: 12.sp), bodyText2: TextStyle(fontSize: 16.sp), ), ), // locale: appLocale.locale, localeResolutionCallback: (locale, supportedLocales) { return Localizations.maybeLocaleOf(context); }, localizationsDelegates: [ GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, S.delegate ], supportedLocales: S.delegate.supportedLocales, home: LoginPage(), onGenerateRoute: (settings) { final String name = settings.name; final Function pageContentBuilder = routers[name]; if (pageContentBuilder != null) { final Route route = MaterialPageRoute( builder: (context) { return pageContentBuilder(context, arguments: settings.arguments); }, settings: settings, ); return route; } return MaterialPageRoute( //未找到页面配置进入登录页 builder: (context) { return LoginPage(); }, settings: settings, ); }, ), ); } }