2024-01-27 16:05:17 +08:00
|
|
|
import 'dart:async';
|
2024-05-18 14:57:02 +08:00
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-27 16:05:17 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
import 'package:get/get.dart';
|
2024-03-09 13:51:42 +08:00
|
|
|
import 'package:star_lock/flavors.dart';
|
2024-06-11 09:22:36 +08:00
|
|
|
import 'package:star_lock/login/login/app_get_version.dart';
|
2024-06-05 14:21:14 +08:00
|
|
|
import 'package:star_lock/mine/about/debug/debug_tool.dart';
|
|
|
|
|
import 'package:star_lock/network/api_provider.dart';
|
|
|
|
|
import 'package:star_lock/network/api_repository.dart';
|
2024-05-18 18:25:39 +08:00
|
|
|
import 'package:star_lock/tools/bugly/bugly_tool.dart';
|
2024-06-11 09:22:36 +08:00
|
|
|
import 'package:star_lock/tools/customer_tool.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
import 'package:star_lock/tools/device_info_service.dart';
|
2024-06-11 09:22:36 +08:00
|
|
|
import 'package:star_lock/tools/pay/wx_pay_tool.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
import 'package:star_lock/tools/platform_info_services.dart';
|
2024-06-05 14:21:14 +08:00
|
|
|
import 'package:star_lock/tools/storage.dart';
|
2024-06-01 13:35:03 +08:00
|
|
|
import 'package:star_lock/tools/xs_jPhush.dart';
|
2024-05-18 14:57:02 +08:00
|
|
|
import 'package:star_lock/translations/trans_lib.dart';
|
|
|
|
|
|
|
|
|
|
import 'app.dart';
|
2024-01-27 16:05:17 +08:00
|
|
|
import 'app_settings/app_settings.dart';
|
2023-08-02 09:22:39 +08:00
|
|
|
import 'tools/store_service.dart';
|
2023-07-10 17:50:31 +08:00
|
|
|
|
2024-01-27 16:05:17 +08:00
|
|
|
// 该文件不可作为编译入口,请查看 flavorizr.yaml 中的说明
|
|
|
|
|
FutureOr<void> main() async {
|
2024-05-03 18:30:45 +08:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
2023-08-26 11:40:40 +08:00
|
|
|
await _setCommonServices();
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
// 设置国际化信息
|
|
|
|
|
await _initTranslation();
|
|
|
|
|
|
2024-06-05 14:21:14 +08:00
|
|
|
final bool isLogin = await getLoginStatus();
|
|
|
|
|
if (isLogin) {
|
|
|
|
|
await privacySDKInitialization();
|
2024-06-11 09:22:36 +08:00
|
|
|
Future<void>.delayed(const Duration(milliseconds: 500), () async{
|
|
|
|
|
final GetAppInfo entity = await ApiRepository.to.getAppInfo();
|
|
|
|
|
CustomerTool.init(entity.data?.wechatServiceUrl ?? '');
|
|
|
|
|
WxPayTool.setAssociationUrl(entity.data!.appSiteUrl!);
|
|
|
|
|
});
|
2024-06-05 14:21:14 +08:00
|
|
|
}
|
2024-05-20 09:45:50 +08:00
|
|
|
|
2024-06-05 14:21:14 +08:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
|
final bool? openDeBug = await Storage.getBool(isOpenDeBug);
|
|
|
|
|
if (openDeBug == true) {
|
|
|
|
|
DeBug.showFloatWidget();
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-06-01 13:35:03 +08:00
|
|
|
|
2024-06-05 14:21:14 +08:00
|
|
|
runApp(MyApp(isLogin: isLogin));
|
2023-10-12 11:24:41 +08:00
|
|
|
|
2024-01-27 16:05:17 +08:00
|
|
|
if (AppPlatform.isAndroid) {
|
2024-05-18 14:57:02 +08:00
|
|
|
const SystemUiOverlayStyle systemUiOverlayStyle =
|
|
|
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
2023-10-12 11:24:41 +08:00
|
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置国际化信息
|
2024-06-05 14:21:14 +08:00
|
|
|
Future<void> _initTranslation() async => TranslationLoader.loadTranslation(
|
2024-05-18 14:57:02 +08:00
|
|
|
zhSource: 'images/lan/lan_zh.json',
|
|
|
|
|
enSource: 'images/lan/lan_en.json',
|
|
|
|
|
keySource: 'images/lan/lan_keys.json',
|
2024-03-07 11:41:06 +08:00
|
|
|
);
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
// 设置包名服务设备信息
|
2024-06-05 14:21:14 +08:00
|
|
|
Future<void> _setCommonServices() async {
|
2023-07-10 17:50:31 +08:00
|
|
|
await Get.putAsync(() => StoreService().init());
|
2024-06-05 14:21:14 +08:00
|
|
|
Get.put(ApiProvider());
|
|
|
|
|
Get.put(ApiRepository(Get.find<ApiProvider>()));
|
2024-03-28 09:51:30 +08:00
|
|
|
if (F.isLite) {
|
2024-03-09 13:51:42 +08:00
|
|
|
//上架审核注释 获取设备信息
|
|
|
|
|
// await Get.putAsync(() => DeviceInfoService().init());
|
|
|
|
|
} else {
|
|
|
|
|
await Get.putAsync(() => DeviceInfoService().init());
|
|
|
|
|
}
|
2023-11-16 10:04:38 +08:00
|
|
|
}
|
2024-06-05 14:21:14 +08:00
|
|
|
|
|
|
|
|
//关于隐私协议的初始化
|
|
|
|
|
Future<void> privacySDKInitialization() async {
|
2024-06-05 16:13:56 +08:00
|
|
|
await Get.putAsync(() => PlatformInfoService().init());
|
2024-06-05 14:21:14 +08:00
|
|
|
await BuglyTool.init();
|
|
|
|
|
await XSJPushProvider().initJPushService();
|
|
|
|
|
}
|