You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.6 KiB

import 'package:bot_toast/bot_toast.dart';
import 'package:cloud_car_internal/constants/app_theme.dart';
import 'package:cloud_car_internal/providers/user_provider.dart';
import 'package:cloud_car_internal/ui/splash/splash.dart';
import 'package:cloud_car_internal/utils/api_client.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_ume/flutter_ume.dart'; // UME 框架
import 'package:flutter_ume_kit_ui/flutter_ume_kit_ui.dart'; // UI 插件包
import 'package:flutter_ume_kit_perf/flutter_ume_kit_perf.dart'; // 性能插件包
import 'package:flutter_ume_kit_show_code/flutter_ume_kit_show_code.dart'; // 代码查看插件包
import 'package:flutter_ume_kit_device/flutter_ume_kit_device.dart'; // 设备信息插件包
import 'package:flutter_ume_kit_console/flutter_ume_kit_console.dart'; // debugPrint 插件包
import 'package:flutter_ume_kit_dio/flutter_ume_kit_dio.dart'; // Dio 网络请求调试工具
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:provider/provider.dart';
void main() {
if (kDebugMode) {
PluginManager.instance // 注册插件
..register(const WidgetInfoInspector())
..register(const WidgetDetailInspector())
..register(const ColorSucker())
..register(AlignRuler())
..register(const ColorPicker()) // 新插件
..register(const TouchIndicator()) // 新插件
..register(Performance())
..register(const ShowCode())
..register(const MemoryInfoPage())
..register(CpuInfoPage())
..register(const DeviceInfoPanel())
..register(Console())
..register(DioInspector(dio: apiClient.dio));
runApp(const UMEWidget(enable: true, child: MyApp())); // 初始
} else {
runApp(const MyApp());
}
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider()),
],
child: ScreenUtilInit(
designSize: const Size(750, 1334),
builder: (context) => GestureDetector(
onTap: () {
//点击输入框外部隐藏键盘⌨️
//只能响应点击非手势识别的组件
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus &&
currentFocus.focusedChild != null) {
FocusManager.instance.primaryFocus!.unfocus();
}
},
child: GetMaterialApp(
onGenerateTitle: (context) => '云云问车',
debugShowCheckedModeBanner: false,
theme: AppTheme.defaultTheme,
home: const SplashPage(),
supportedLocales: const [Locale('zh')],
locale: const Locale('zh'),
localizationsDelegates: GlobalMaterialLocalizations.delegates,
//builder: BotToastInit(),
builder: (context, child) {
ScreenUtil.setContext(context);
return MediaQuery(
//设置文字大小不随系统设置改变
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window).copyWith(textScaleFactor: 1.0),
child: BotToastInit().call(context, child),
);
},
navigatorObservers: [BotToastNavigatorObserver()],
),
),
),
);
}
}