63 lines
2.0 KiB
Dart
Executable File
63 lines
2.0 KiB
Dart
Executable File
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/flavors.dart';
|
|
import 'package:star_lock/tools/device_info_service.dart';
|
|
import 'package:star_lock/tools/platform_info_services.dart';
|
|
import 'package:star_lock/translations/trans_lib.dart';
|
|
|
|
import 'app.dart';
|
|
import 'app_settings/app_settings.dart';
|
|
import 'tools/store_service.dart';
|
|
|
|
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
|
FutureOr<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await _setCommonServices();
|
|
|
|
// 设置国际化信息
|
|
await _initTranslation();
|
|
|
|
//错误日志监控
|
|
FlutterError.onError = (FlutterErrorDetails details) async {
|
|
AppLog.log('error:${details.exception.toString()}',
|
|
stackTrace: details.stack, error: true);
|
|
Zone.current.handleUncaughtError(details.exception, details.stack!);
|
|
};
|
|
|
|
//错误日志监控
|
|
runZonedGuarded<Future<void>>(() async {
|
|
runApp(const MyApp());
|
|
}, (Object error, StackTrace stackTrace) async {
|
|
AppLog.log('error:$error', stackTrace: stackTrace, error: true);
|
|
});
|
|
|
|
if (AppPlatform.isAndroid) {
|
|
const SystemUiOverlayStyle systemUiOverlayStyle =
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
|
}
|
|
}
|
|
|
|
// 设置国际化信息
|
|
Future _initTranslation() async => TranslationLoader.loadTranslation(
|
|
zhSource: 'images/lan/lan_zh.json',
|
|
enSource: 'images/lan/lan_en.json',
|
|
keySource: 'images/lan/lan_keys.json',
|
|
);
|
|
|
|
// 设置包名服务设备信息
|
|
Future _setCommonServices() async {
|
|
await Get.putAsync(() => StoreService().init());
|
|
await Get.putAsync(() => PlatformInfoService().init());
|
|
if (F.isLite) {
|
|
//上架审核注释 获取设备信息
|
|
// await Get.putAsync(() => DeviceInfoService().init());
|
|
} else {
|
|
await Get.putAsync(() => DeviceInfoService().init());
|
|
}
|
|
}
|