AI-Clipboard/lib/main.dart
fengshengxiong 50c2738fc5 搭建框架:
1.状态管理、路由、依赖注入
2.屏幕适配
3.日志封装
2024-05-07 18:16:51 +08:00

55 lines
1.7 KiB
Dart

import 'package:ai_clipboard/routes/app_pages.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'common/components/easy_loading.dart';
import 'theme/app_themes.dart';
void main() {
runApp(const MyApp());
// 配置EasyLoading
configLoading();
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final easyLoading = EasyLoading.init();
return ScreenUtilInit(
// 设计稿中设备的尺寸(单位随意,建议dp,但在使用过程中必须保持一致)
designSize: const Size(360, 690),
// 是否根据宽度/高度中的最小值适配文字
minTextAdapt: true,
// 支持分屏尺寸
splitScreenMode: true,
builder: (context, child) {
return GetMaterialApp(
title: 'AI Clipboard',
theme: lightTheme,
darkTheme: darkTheme,
themeMode: ThemeMode.light,
getPages: AppPages.routes,
initialRoute: AppPages.initial,
builder: (context, widget) {
widget = easyLoading(context, widget);
return MediaQuery(
// 设置文字大小不随系统设置改变
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
child: KeyboardDismissOnTap(
// 点击其他交互式组件,也关闭键盘
dismissOnCapturedTaps: true,
child: widget,
),
);
},
);
},
);
}
}