diff --git a/analysis_options.yaml b/analysis_options.yaml index ac13dd4..2f4168b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -32,6 +32,8 @@ analyzer: exclude: - "**/*.g.dart" - "**/*.freezed.dart" + - "**/generated/*.dart" + - "**/generated/**/*.dart" errors: invalid_annotation_target: ignore # Additional information about this file can be found at diff --git a/lib/app.dart b/lib/app.dart index 5c4e829..b136897 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -81,7 +81,7 @@ GoRouter router(Ref ref) { pageBuilder: (context, state) => myPageBuilder(context, state, const AdvancedLocalizationUI())) ], ), - GoRoute(path: '/tools', builder: (_, __) => const SizedBox(), routes: [ + GoRoute(path: '/tools', builder: (_, _) => const SizedBox(), routes: [ GoRoute( path: 'unp4kc', pageBuilder: (context, state) => myPageBuilder(context, state, const UnP4kcUI()), @@ -295,7 +295,7 @@ class AppGlobalModel extends _$AppGlobalModel { } } - void changeLocale(value) async { + void changeLocale(dynamic value) async { final appConfBox = await Hive.openBox("app_conf"); if (value is Locale) { if (value.languageCode == "auto") { diff --git a/lib/common/conf/conf.dart b/lib/common/conf/conf.dart index 09d31d1..03432aa 100644 --- a/lib/common/conf/conf.dart +++ b/lib/common/conf/conf.dart @@ -21,7 +21,7 @@ class ConstConf { class AppConf { static List? _networkGameChannels; - static setNetworkChannels(List? channels) { + static void setNetworkChannels(List? channels) { _networkGameChannels = channels; } diff --git a/lib/common/helper/system_helper.dart b/lib/common/helper/system_helper.dart index e83ee59..a1e9be6 100644 --- a/lib/common/helper/system_helper.dart +++ b/lib/common/helper/system_helper.dart @@ -6,7 +6,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart'; class SystemHelper { static String powershellPath = "powershell.exe"; - static initPowershellPath() async { + static Future initPowershellPath() async { try { var result = await Process.run(powershellPath, ["echo", "pong"]); if (!result.stdout.toString().startsWith("pong") && powershellPath == "powershell.exe") { @@ -58,7 +58,7 @@ class SystemHelper { return result.stderr; } - static doRemoveNvmePath() async { + static Future doRemoveNvmePath() async { try { var result = await Process.run(powershellPath, [ "Clear-ItemProperty", @@ -110,7 +110,7 @@ class SystemHelper { return ""; } - static killRSILauncher() async { + static Future killRSILauncher() async { var psr = await Process.run(powershellPath, ["ps", "\"RSI Launcher\"", "|select -expand id"]); if (psr.stderr == "") { for (var value in (psr.stdout ?? "").toString().split("\n")) { @@ -139,7 +139,7 @@ class SystemHelper { } } - static checkAndLaunchRSILauncher(String path) async { + static Future checkAndLaunchRSILauncher(String path) async { // check running and kill await killRSILauncher(); // launch @@ -254,7 +254,7 @@ foreach ($adapter in $adapterMemory) { return int.parse(binaryString, radix: 2).toRadixString(16).padLeft(hexDigits, '0').toUpperCase(); } - static Future openDir(path, {bool isFile = false}) async { + static Future openDir(dynamic path, {bool isFile = false}) async { dPrint("SystemHelper.openDir path === $path"); if (Platform.isWindows) { await Process.run( diff --git a/lib/common/io/rs_http.dart b/lib/common/io/rs_http.dart index 558a5f6..ac0956f 100644 --- a/lib/common/io/rs_http.dart +++ b/lib/common/io/rs_http.dart @@ -7,7 +7,7 @@ import 'package:starcitizen_doctor/common/rust/api/http_api.dart'; import 'package:starcitizen_doctor/common/rust/http_package.dart'; class RSHttp { - static init() async { + static Future init() async { await rust_http.setDefaultHeader(headers: { "User-Agent": "SCToolBox/${ConstConf.appVersion} (${ConstConf.appVersionCode})${ConstConf.isMSE ? "" : " DEV"} RSHttp" diff --git a/lib/common/utils/log.dart b/lib/common/utils/log.dart index fdd3ddd..0c285e9 100644 --- a/lib/common/utils/log.dart +++ b/lib/common/utils/log.dart @@ -8,7 +8,7 @@ export 'package:starcitizen_doctor/generated/l10n.dart'; var _logLock = Lock(); File? _logFile; -void dPrint(src) async { +void dPrint(dynamic src) async { if (kDebugMode) { print(src); return; diff --git a/lib/common/utils/multi_window_manager.dart b/lib/common/utils/multi_window_manager.dart index 95e7bf9..44f4e3f 100644 --- a/lib/common/utils/multi_window_manager.dart +++ b/lib/common/utils/multi_window_manager.dart @@ -50,7 +50,7 @@ class MultiWindowManager { // sendAppStateBroadcast(appGlobalState); } - static sendAppStateBroadcast(AppGlobalState appGlobalState) { + static void sendAppStateBroadcast(AppGlobalState appGlobalState) { DesktopMultiWindow.invokeMethod( 0, 'app_state_broadcast', diff --git a/lib/main.dart b/lib/main.dart index 1aebfa2..5299e5f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -27,7 +27,7 @@ void main(List args) async { runApp(const ProviderScope(child: App())); } -_initWindow() async { +Future _initWindow() async { await windowManager.ensureInitialized(); await windowManager.setTitleBarStyle( TitleBarStyle.hidden, diff --git a/lib/provider/unp4kc.dart b/lib/provider/unp4kc.dart index df0e2c3..c5c2236 100644 --- a/lib/provider/unp4kc.dart +++ b/lib/provider/unp4kc.dart @@ -219,7 +219,7 @@ class Unp4kCModel extends _$Unp4kCModel { } } - openFile(String filePath) async { + Future openFile(String filePath) async { final tempDir = await getTemporaryDirectory(); final tempPath = "${tempDir.absolute.path}\\SCToolbox_unp4kc\\${SCLoggerHelper.getGameChannelID(getGamePath())}\\"; @@ -229,7 +229,7 @@ class Unp4kCModel extends _$Unp4kCModel { extractFile(filePath, tempPath, mode: "extract_open"); } - extractFile(String filePath, String outputPath, + Future extractFile(String filePath, String outputPath, {String mode = "extract"}) async { // remove first \\ if (filePath.startsWith("\\")) { diff --git a/lib/ui/about/about_ui.dart b/lib/ui/about/about_ui.dart index 18adf86..9cdf671 100644 --- a/lib/ui/about/about_ui.dart +++ b/lib/ui/about/about_ui.dart @@ -567,7 +567,7 @@ class AboutUI extends HookConsumerWidget { ); } - _onCheckUpdate(BuildContext context, WidgetRef ref) async { + Future _onCheckUpdate(BuildContext context, WidgetRef ref) async { if (ConstConf.isMSE) { launchUrlString("ms-windows-store://pdp/?productid=9NF3SWFWNKL1"); return; diff --git a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart b/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart index 23e2e06..6555ac3 100644 --- a/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart +++ b/lib/ui/home/dialogs/home_game_login_dialog_ui_model.dart @@ -118,7 +118,7 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel { } // ignore: avoid_build_context_in_providers - goWebView(BuildContext context, String title, String url, + Future goWebView(BuildContext context, String title, String url, {bool useLocalization = false, bool loginMode = false, RsiLoginCallback? rsiLoginCallback, diff --git a/lib/ui/home/downloader/home_downloader_ui_model.dart b/lib/ui/home/downloader/home_downloader_ui_model.dart index 0292a29..d98f5a8 100644 --- a/lib/ui/home/downloader/home_downloader_ui_model.dart +++ b/lib/ui/home/downloader/home_downloader_ui_model.dart @@ -64,7 +64,7 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel { return state; } - onTapButton(BuildContext context, String key) async { + Future onTapButton(BuildContext context, String key) async { final aria2cState = ref.read(aria2cModelProvider); switch (key) { case "pause_all": @@ -194,14 +194,14 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel { return l; } - openFolder(Aria2Task task) { + void openFolder(Aria2Task task) { final f = getFilesFormTask(task).firstOrNull; if (f != null) { SystemHelper.openDir(File(f.path!).absolute.path.replaceAll("/", "\\")); } } - _listenDownloader() async { + Future _listenDownloader() async { try { while (true) { final aria2cState = ref.read(aria2cModelProvider); diff --git a/lib/ui/home/game_doctor/game_doctor_ui.dart b/lib/ui/home/game_doctor/game_doctor_ui.dart index d6b1f4b..3b88bfd 100644 --- a/lib/ui/home/game_doctor/game_doctor_ui.dart +++ b/lib/ui/home/game_doctor/game_doctor_ui.dart @@ -285,7 +285,7 @@ class HomeGameDoctorUI extends HookConsumerWidget { ); } - _onTapButton( + Future _onTapButton( BuildContext context, String key, HomeUIModelState homeState) async { switch (key) { case "rsi_log": diff --git a/lib/ui/home/game_doctor/game_doctor_ui_model.dart b/lib/ui/home/game_doctor/game_doctor_ui_model.dart index ae22ab3..45e6580 100644 --- a/lib/ui/home/game_doctor/game_doctor_ui_model.dart +++ b/lib/ui/home/game_doctor/game_doctor_ui_model.dart @@ -113,7 +113,7 @@ class HomeGameDoctorUIModel extends _$HomeGameDoctorUIModel { } // ignore: avoid_build_context_in_providers - doCheck(BuildContext context) async { + Future doCheck(BuildContext context) async { if (state.isChecking) return; state = state.copyWith( isChecking: true, lastScreenInfo: S.current.doctor_action_analyzing); @@ -124,7 +124,7 @@ class HomeGameDoctorUIModel extends _$HomeGameDoctorUIModel { } // ignore: avoid_build_context_in_providers - _statCheck(BuildContext context) async { + Future _statCheck(BuildContext context) async { final homeState = ref.read(homeUIModelProvider); final scInstalledPath = homeState.scInstalledPath!; diff --git a/lib/ui/home/home_ui.dart b/lib/ui/home/home_ui.dart index 379cc9a..89be41e 100644 --- a/lib/ui/home/home_ui.dart +++ b/lib/ui/home/home_ui.dart @@ -718,7 +718,7 @@ class HomeUI extends HookConsumerWidget { ); } - _showPlacard(BuildContext context, HomeUIModelState homeState) { + void _showPlacard(BuildContext context, HomeUIModelState homeState) { switch (homeState.appPlacardData?.linkType) { case "external": launchUrlString(homeState.appPlacardData?.link); @@ -736,7 +736,7 @@ class HomeUI extends HookConsumerWidget { } } - _onTapFestival(BuildContext context) { + void _onTapFestival(BuildContext context) { showDialog(context: context, builder: (context) => const HomeCountdownDialogUI()); } diff --git a/lib/ui/home/home_ui_model.dart b/lib/ui/home/home_ui_model.dart index 295d8bb..b54ef97 100644 --- a/lib/ui/home/home_ui_model.dart +++ b/lib/ui/home/home_ui_model.dart @@ -69,7 +69,7 @@ class HomeUIModel extends _$HomeUIModel { return state; } - closePlacard() async { + Future closePlacard() async { final box = await Hive.openBox("app_conf"); await box.put("close_placard", state.appPlacardData?.version); state = state.copyWith(appPlacardData: null); @@ -281,7 +281,7 @@ class HomeUIModel extends _$HomeUIModel { } // ignore: avoid_build_context_in_providers - launchRSI(BuildContext context) async { + Future launchRSI(BuildContext context) async { if (state.scInstalledPath == "not_install") { showToast(context, S.current.home_info_valid_installation_required); return; @@ -312,7 +312,7 @@ class HomeUIModel extends _$HomeUIModel { ref.read(localizationUIModelProvider.notifier).onChangeGameInstallPath(value); } - doLaunchGame( + Future doLaunchGame( // ignore: avoid_build_context_in_providers BuildContext context, String launchExe, diff --git a/lib/ui/home/input_method/input_method_dialog_ui.dart b/lib/ui/home/input_method/input_method_dialog_ui.dart index 7150e05..0684993 100644 --- a/lib/ui/home/input_method/input_method_dialog_ui.dart +++ b/lib/ui/home/input_method/input_method_dialog_ui.dart @@ -239,7 +239,7 @@ class InputMethodDialogUI extends HookConsumerWidget { } } - _onSwitchAutoTranslate( + Future _onSwitchAutoTranslate( BuildContext context, InputMethodDialogUIModel model, bool b) async { if (b) { final ok = await showConfirmDialogs( diff --git a/lib/ui/home/input_method/input_method_dialog_ui_model.dart b/lib/ui/home/input_method/input_method_dialog_ui_model.dart index a1b9409..e1baf4e 100644 --- a/lib/ui/home/input_method/input_method_dialog_ui_model.dart +++ b/lib/ui/home/input_method/input_method_dialog_ui_model.dart @@ -148,7 +148,7 @@ class InputMethodDialogUIModel extends _$InputMethodDialogUIModel { } } - toggleAutoTranslate(bool b) async { + Future toggleAutoTranslate(bool b) async { state = state.copyWith(isEnableAutoTranslate: b); final appConf = await Hive.openBox("app_conf"); await appConf.put("isEnableAutoTranslate", b); diff --git a/lib/ui/home/input_method/server.dart b/lib/ui/home/input_method/server.dart index 070c971..b46b177 100644 --- a/lib/ui/home/input_method/server.dart +++ b/lib/ui/home/input_method/server.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:io'; import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; diff --git a/lib/ui/home/input_method/server_qr_dialog_ui.dart b/lib/ui/home/input_method/server_qr_dialog_ui.dart index f5d4cbc..7a2b5a1 100644 --- a/lib/ui/home/input_method/server_qr_dialog_ui.dart +++ b/lib/ui/home/input_method/server_qr_dialog_ui.dart @@ -24,7 +24,7 @@ class ServerQrState extends _$ServerQrState { _context = context; } - popDialog() { + void popDialog() { _context?.pop(); } } diff --git a/lib/ui/home/localization/advanced_localization_ui.dart b/lib/ui/home/localization/advanced_localization_ui.dart index 4899332..0500c1f 100644 --- a/lib/ui/home/localization/advanced_localization_ui.dart +++ b/lib/ui/home/localization/advanced_localization_ui.dart @@ -225,7 +225,7 @@ class AdvancedLocalizationUI extends HookConsumerWidget { ); } - _showContent(BuildContext context, AppAdvancedLocalizationClassKeysData item) { + void _showContent(BuildContext context, AppAdvancedLocalizationClassKeysData item) { showDialog( context: context, builder: (BuildContext context) { diff --git a/lib/ui/home/localization/localization_ui_model.dart b/lib/ui/home/localization/localization_ui_model.dart index 1a1145b..680dd18 100644 --- a/lib/ui/home/localization/localization_ui_model.dart +++ b/lib/ui/home/localization/localization_ui_model.dart @@ -455,7 +455,7 @@ class LocalizationUIModel extends _$LocalizationUIModel { }; } - _updateStatus() async { + Future _updateStatus() async { final iniPath = "${_scDataDir.absolute.path}\\Localization\\${state.selectedLanguage}\\global.ini"; final patchStatus = MapEntry(await _getLangCfgEnableLang(lang: state.selectedLanguage!), await _getInstalledIniVersion(iniPath)); diff --git a/lib/ui/home/performance/performance_ui_model.dart b/lib/ui/home/performance/performance_ui_model.dart index 4b95706..4d74f4b 100644 --- a/lib/ui/home/performance/performance_ui_model.dart +++ b/lib/ui/home/performance/performance_ui_model.dart @@ -73,7 +73,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { showGraphicsPerformanceTip: v != _graphicsPerformanceTipVersion); } - _readConf() async { + Future _readConf() async { if (state.performanceMap == null) return; state = state.copyWith(enabled: true); @@ -95,14 +95,14 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { } } - closeTip() async { + Future closeTip() async { final box = await Hive.openBox("app_conf"); await box.put( "close_graphics_performance_tip", _graphicsPerformanceTipVersion); _init(); } - onChangePreProfile(String key) { + void onChangePreProfile(String key) { switch (key) { case "low": state.performanceMap?.forEach((key, v) { @@ -144,11 +144,11 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { state = state.copyWith(); } - refresh() async { + Future refresh() async { _init(); } - clean(BuildContext context) async { + Future clean(BuildContext context) async { state = state.copyWith( workingString: S.current.performance_info_delete_config_file); if (await confFile.exists()) { @@ -164,7 +164,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { state = state.copyWith(workingString: ""); } - cleanShaderCache(BuildContext? context) async { + Future cleanShaderCache(BuildContext? context) async { final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath(); final l = await Directory(gameShaderCachePath!).list(recursive: false).toList(); @@ -181,7 +181,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { } } - applyProfile(bool cleanShader) async { + Future applyProfile(bool cleanShader) async { if (state.performanceMap == null) return; AnalyticsApi.touch("performance_apply"); state = state.copyWith( @@ -222,7 +222,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel { state = state.copyWith(workingString: ""); } - updateState() { + void updateState() { state = state.copyWith(); } } diff --git a/lib/ui/index_ui.dart b/lib/ui/index_ui.dart index 8327129..98fe9bb 100644 --- a/lib/ui/index_ui.dart +++ b/lib/ui/index_ui.dart @@ -164,7 +164,7 @@ class IndexUI extends HookConsumerWidget { ); } - _goDownloader(BuildContext context) { + void _goDownloader(BuildContext context) { context.push('/index/downloader'); } } \ No newline at end of file diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart index 572e2ed..c7ec047 100644 --- a/lib/ui/settings/settings_ui_model.dart +++ b/lib/ui/settings/settings_ui_model.dart @@ -116,7 +116,7 @@ class SettingsUIModel extends _$SettingsUIModel { } } - _saveCustomPath(String pathKey, String dir) async { + Future _saveCustomPath(String pathKey, String dir) async { final confBox = await Hive.openBox("app_conf"); await confBox.put(pathKey, dir); } @@ -210,7 +210,7 @@ class SettingsUIModel extends _$SettingsUIModel { _initState(); } - showLogs() async { + Future showLogs() async { SystemHelper.openDir(getDPrintFile()?.absolute.path.replaceAll("/", "\\"), isFile: true); } diff --git a/lib/ui/splash_ui.dart b/lib/ui/splash_ui.dart index 9cc1b71..e88c0f6 100644 --- a/lib/ui/splash_ui.dart +++ b/lib/ui/splash_ui.dart @@ -90,7 +90,7 @@ class SplashUI extends HookConsumerWidget { context.go("/index"); } - _showAlert(BuildContext context, Box appConf) async { + Future _showAlert(BuildContext context, Box appConf) async { final userOk = await showConfirmDialogs( context, S.current.app_splash_dialog_u_a_p_p, diff --git a/lib/ui/tools/tools_ui_model.dart b/lib/ui/tools/tools_ui_model.dart index 9575be2..e9eb890 100644 --- a/lib/ui/tools/tools_ui_model.dart +++ b/lib/ui/tools/tools_ui_model.dart @@ -63,7 +63,7 @@ class ToolsUIModel extends _$ToolsUIModel { return state; } - loadToolsCard(BuildContext context, {bool skipPathScan = false}) async { + Future loadToolsCard(BuildContext context, {bool skipPathScan = false}) async { if (state.isItemLoading) return; var items = []; state = state.copyWith(items: items, isItemLoading: true); @@ -352,7 +352,7 @@ class ToolsUIModel extends _$ToolsUIModel { SystemHelper.checkAndLaunchRSILauncher(state.rsiLauncherInstalledPath); } - openDir(path) async { + Future openDir(dynamic path) async { SystemHelper.openDir(path); } @@ -526,7 +526,7 @@ class ToolsUIModel extends _$ToolsUIModel { return true; } - _onChangePhotographyMode(BuildContext context, bool isEnable) async { + Future _onChangePhotographyMode(BuildContext context, bool isEnable) async { _checkPhotographyStatus(context, setMode: !isEnable).unwrap(context: context); loadToolsCard(context, skipPathScan: true); } @@ -539,15 +539,15 @@ class ToolsUIModel extends _$ToolsUIModel { state = state.copyWith(rsiLauncherInstalledPath: s); } - _doHostsBooster(BuildContext context) async { + Future _doHostsBooster(BuildContext context) async { showDialog(context: context, builder: (BuildContext context) => const HostsBoosterDialogUI()); } - _unp4kc(BuildContext context) async { + Future _unp4kc(BuildContext context) async { context.push("/tools/unp4kc"); } - static rsiEnhance(BuildContext context, {bool showNotGameInstallMsg = false}) async { + static Future rsiEnhance(BuildContext context, {bool showNotGameInstallMsg = false}) async { if ((await SystemHelper.getPID("\"RSI Launcher\"")).isNotEmpty) { if (!context.mounted) return; showToast(context, S.current.tools_action_info_rsi_launcher_running_warning, @@ -562,7 +562,7 @@ class ToolsUIModel extends _$ToolsUIModel { )); } - _showLogAnalyze(BuildContext context) async { + Future _showLogAnalyze(BuildContext context) async { if (state.scInstalledPath.isEmpty) { showToast(context, S.current.tools_action_info_valid_game_directory_needed); return; diff --git a/lib/ui/webview/webview.dart b/lib/ui/webview/webview.dart index 8ee3c7f..a9b2c1a 100644 --- a/lib/ui/webview/webview.dart +++ b/lib/ui/webview/webview.dart @@ -213,11 +213,11 @@ class WebViewModel { return finalUrl; } - launch(String url, AppVersionData appVersionData) async { + Future launch(String url, AppVersionData appVersionData) async { webview.launch(await _handleMirrorsUrl(url, appVersionData)); } - initLocalization(AppWebLocalizationVersionsData v) async { + Future initLocalization(AppWebLocalizationVersionsData v) async { localizationScript = await rootBundle.loadString('assets/web_script.js'); /// https://github.com/CxJuice/Uex_Chinese_Translate diff --git a/lib/widgets/src/countdown_time_text.dart b/lib/widgets/src/countdown_time_text.dart index 74117d7..5e09755 100644 --- a/lib/widgets/src/countdown_time_text.dart +++ b/lib/widgets/src/countdown_time_text.dart @@ -35,7 +35,7 @@ class _CountdownTimeTextState extends State { super.dispose(); } - _onUpdateTime(_) { + void _onUpdateTime(_) { final now = DateTime.now(); final dur = widget.targetTime.difference(now); setState(() { diff --git a/lib/widgets/widgets.dart b/lib/widgets/widgets.dart index 15d27e6..9b3f4b2 100644 --- a/lib/widgets/widgets.dart +++ b/lib/widgets/widgets.dart @@ -212,7 +212,7 @@ class LoadingWidget extends HookConsumerWidget { } } -addPostFrameCallback(Function() callback) { +void addPostFrameCallback(Function() callback) { WidgetsBinding.instance.addPostFrameCallback((_) { callback(); });