import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import 'package:isekai_wiki/global.dart'; import 'package:isekai_wiki/models/lifecycle.dart'; import 'package:isekai_wiki/models/site_config.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'app.dart'; Future init() async { if (kIsWeb) { // 设置web origin Global.webOrigin = Uri.base.origin; } await GetStorage.init(); // 检测是否已激活 var storage = GetStorage(); Global.isAppActive = storage.read("appActive") ?? false; } Future postInit() async { Global.packageInfo = await PackageInfo.fromPlatform(); if (!kIsWeb && GetPlatform.isAndroid) { // 启用高刷 try { if (kDebugMode) { var modes = await FlutterDisplayMode.supported; print("Refresh rate list:"); // ignore: avoid_print modes.forEach(print); print("Preferred refresh rate:"); print(await FlutterDisplayMode.preferred); } await FlutterDisplayMode.setHighRefreshRate(); } catch (err) { if (kDebugMode) { print("Cannot set to high refresh rate: "); print(err); } } } WidgetsFlutterBinding.ensureInitialized(); if (GetPlatform.isAndroid) { await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true); } } Future main() async { await init(); Get.put(SiteConfigController()); Get.put(LifeCycleController()); runApp(const IsekaiWikiApp()); postInit(); }