77 lines
2.4 KiB
Dart
77 lines
2.4 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:tone_snap/components/base_easyloading.dart';
|
|
import 'package:tone_snap/data/storage/hive_storage.dart';
|
|
import 'package:tone_snap/res/themes/app_themes.dart';
|
|
import 'package:tone_snap/res/values/strings.dart';
|
|
import 'package:tone_snap/routes/app_pages.dart';
|
|
import 'package:tone_snap/routes/app_routes.dart';
|
|
import 'package:tone_snap/utils/file_util.dart';
|
|
import 'package:tone_snap/utils/local_path_util.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// 初始化Hive
|
|
await initHive();
|
|
|
|
// 竖屏
|
|
SystemChrome.setPreferredOrientations([
|
|
DeviceOrientation.portraitUp,
|
|
DeviceOrientation.portraitDown,
|
|
]);
|
|
|
|
runApp(const MyApp());
|
|
|
|
if (Platform.isAndroid) {
|
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
systemNavigationBarColor: Colors.black,
|
|
systemNavigationBarIconBrightness: Brightness.light,
|
|
));
|
|
}
|
|
|
|
// 删除缓存文件
|
|
FileUtil.deleteAllFilesInDirectory(await LocalPathUtil.getRecordingsDir());
|
|
FileUtil.deleteAllFilesInDirectory(await LocalPathUtil.getAssetsDir());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final easyLoading = EasyLoading.init();
|
|
return ScreenUtilInit(
|
|
// 以设计稿的尺寸为基准进行适配
|
|
designSize: const Size(375, 812),
|
|
minTextAdapt: true,
|
|
builder: (context, child) {
|
|
return GetMaterialApp(
|
|
title: appName,
|
|
debugShowCheckedModeBanner: false,
|
|
theme: appTheme,
|
|
darkTheme: appTheme,
|
|
themeMode: ThemeMode.light,
|
|
getPages: AppPages.routes,
|
|
initialRoute: AppRoutes.initial,
|
|
builder: (context, widget) {
|
|
BaseEasyLoading.initGlobalConfig();
|
|
widget = easyLoading(context, widget);
|
|
return MediaQuery(
|
|
// 设置文字大小不随系统设置改变
|
|
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
|
|
child: widget,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|