chore(project): 初始化项目基础配置文件
- 添加 CodeGraph、Android 和通用 gitignore 配置 - 创建项目元数据文件跟踪 Flutter 项目属性 - 添加 Codex AI 指导文档 AGENTS.md 说明项目架构 - 配置代码分析选项 analysis_options.yaml - 设置 Android 应用清单权限和 Kiosk 模式配置 - 实现中英文国际化支持 AppLocalizations - 配置 GoRouter 应用路由导航 - 创建明亮工业控制风格的主题配置 AppTheme
This commit is contained in:
61
lib/main.dart
Normal file
61
lib/main.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
|
||||
import 'core/router/app_router.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'core/localization/app_localizations.dart';
|
||||
import 'core/localization/locale_provider.dart';
|
||||
import 'core/database/database_service.dart';
|
||||
|
||||
/// 应用入口
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Kiosk 模式:隐藏系统状态栏和导航栏
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
||||
|
||||
// 固定横屏
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
|
||||
|
||||
final db = DatabaseService.instance;
|
||||
await db.database;
|
||||
await db.initTestData();
|
||||
runApp(const ProviderScope(child: KuaishaiApp()));
|
||||
}
|
||||
|
||||
/// 应用主体
|
||||
class KuaishaiApp extends ConsumerWidget {
|
||||
const KuaishaiApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final router = ref.watch(goRouterProvider);
|
||||
final locale = ref.watch(localeProvider);
|
||||
|
||||
return MaterialApp.router(
|
||||
title: '污水毒品快检一体机',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme(),
|
||||
darkTheme: AppTheme.darkTheme(),
|
||||
themeMode: ThemeMode.light,
|
||||
|
||||
// 国际化配置
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('zh', 'CN'),
|
||||
Locale('en', 'US'),
|
||||
],
|
||||
locale: locale,
|
||||
|
||||
// 路由配置
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user