|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:get/get_navigation/src/root/get_material_app.dart';
|
|
|
|
import 'package:get_storage/get_storage.dart';
|
|
|
|
import 'package:problem_check_system/app/routes/app_pages.dart';
|
|
|
|
import 'package:problem_check_system/app/routes/app_routes.dart'; // 导入路由常量
|
|
|
|
import 'package:problem_check_system/app/bindings/initial_binding.dart';
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
// 确保 Flutter Binding 已初始化
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// 设置应用为竖屏模式
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
DeviceOrientation.portraitDown,
|
|
|
|
]);
|
|
|
|
// 初始化 GetStorage,这是关键步骤
|
|
|
|
await GetStorage.init();
|
|
|
|
// Add this line
|
|
|
|
await ScreenUtil.ensureScreenSize();
|
|
|
|
|
|
|
|
runApp(const MainApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MainApp extends StatelessWidget {
|
|
|
|
const MainApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
// 填入设计稿中设备的屏幕尺寸, 单位dp
|
|
|
|
return ScreenUtilInit(
|
|
|
|
designSize: const Size(375, 812),
|
|
|
|
minTextAdapt: true,
|
|
|
|
splitScreenMode: true,
|
|
|
|
builder: (context, _) {
|
|
|
|
// 使用 _ 忽略 child 参数
|
|
|
|
return GetMaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: '问题检查系统', // 使用更有意义的应用标题
|
|
|
|
theme: ThemeData(useMaterial3: true, primarySwatch: Colors.blue),
|
|
|
|
// 仅使用 GetX 路由系统
|
|
|
|
initialRoute: AppRoutes.login, // 使用路由常量作为初始页面
|
|
|
|
initialBinding: InitialBinding(), // 如果有全局绑定,继续保留
|
|
|
|
getPages: AppPages.routes, // 绑定所有路由
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|