import 'dart:io'; import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:ftrecruiter/services_injection.dart'; import 'package:get/get.dart'; import 'package:ftrecruiter/app_binding.dart'; import 'package:ftrecruiter/comm/utils/device_utils.dart'; import 'package:ftrecruiter/comm/utils/handle_error_utils.dart'; import 'package:ftrecruiter/comm/utils/log_utils.dart'; import 'package:ftrecruiter/comm/widget/dialog/custom_loading_widget.dart'; import 'package:ftrecruiter/comm/widget/dialog/custom_toast_widget.dart'; import 'package:ftrecruiter/local/language/translation_service.dart'; import 'package:ftrecruiter/local/theme/theme_config.dart'; import 'package:ftrecruiter/router/getx_router_observer.dart'; import 'package:ftrecruiter/router/page_router.dart'; void main() async { //框架初始化 WidgetsFlutterBinding.ensureInitialized(); //注入Service // await ServicesInjection.init(); // SP初始化 await SpUtil.getInstance(); // 设备信息初始化 - 判断运行在哪一个平台 await Device.initDeviceInfo(); //运行App handleError(() => runApp(MyApp())); //处理状态栏 SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]); //沉浸式 if (Platform.isAndroid) { SystemUiOverlayStyle style = const SystemUiOverlayStyle( statusBarColor: Colors.transparent, //设置为黑色字体 statusBarIconBrightness: Brightness.dark); SystemChrome.setSystemUIOverlayStyle(style); } } class MyApp extends StatelessWidget { MyApp({Key? key}) : super(key: key) { //Log框架初始化 Log.init(); } @override Widget build(BuildContext context) { //路由管理,状态管理,依赖管理一切都始于GetMaterialApp return GetMaterialApp( //顶部是否展示Debug图标 debugShowCheckedModeBanner: true, //是否展示Log enableLog: true, //默认路由与路由表的加载 initialRoute: RouterPath.SPLASH, getPages: PageRouter.routes, //对原生导航的兼容 navigatorObservers: [GetXRouterObserver()], //默认页面动画 defaultTransition: Transition.rightToLeft, //异步依赖注入ApiService ApiRepository等对象 initialBinding: AppBinding(), smartManagement: SmartManagement.keepFactory, //网页Title显示 title: 'FullTime Recruiter', //样式相关 theme: ThemeConfig.lightTheme, darkTheme: ThemeConfig.darkTheme, themeMode: ThemeMode.system, //本地化相关 locale: TranslationService.locale, fallbackLocale: TranslationService.fallbackLocale, translations: TranslationService(), //SmartDialog初始化默认Loading与Toast builder: FlutterSmartDialog.init( toastBuilder: (String msg) { return CustomToastWidget(msg: msg); }, loadingBuilder: (String msg) { return CustomLoadingWidget(msg: 'loading'.tr); }, ), ); } }