diff --git a/CHANGELOG.md b/CHANGELOG.md index 61b87b1..dc6a5e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,13 @@ ### Improvement - 优化了FSRS学习机制 +- 听写界面不熄屏 +- 优化解压逻辑,避免主线程卡死 ### Fix - 修复了可能的复习列表重复问题 +- 补全控制器销毁逻辑,避免内存泄露 ## v1.0.0 - 2026-3-18 - (100000) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 7b0389f..eb1f5e9 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -21,12 +21,12 @@ android { compileOptions { isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + jvmTarget = JavaVersion.VERSION_17.toString() } defaultConfig { diff --git a/lib/funcs/ui.dart b/lib/funcs/ui.dart index 236cd4d..1fdda31 100644 --- a/lib/funcs/ui.dart +++ b/lib/funcs/ui.dart @@ -445,16 +445,24 @@ class _ChooseButtonBoxState extends State { setState(() { bool? ans = widget.chose(widget.index); if(ans != null) { - color = Colors.amber; - Future.delayed(widget.isAnimated ? Durations.medium4 : Duration(), (){ - setState(() { - if(ans) { - color = Colors.greenAccent; - } else { - color = Colors.redAccent; - } + if(widget.isAnimated) { + color = Colors.amber; + Future.delayed(Durations.medium4, (){ + setState(() { + if(ans) { + color = Colors.greenAccent; + } else { + color = Colors.redAccent; + } + }); }); - }); + } else { + if(ans) { + color = Colors.greenAccent; + } else { + color = Colors.redAccent; + } + } } else { color = Theme.of(context).colorScheme.onPrimary.withAlpha(150); } @@ -932,6 +940,12 @@ class _SpellQuestion extends State { }); } + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建拼写题页面,主单词: ${widget.word.arabic}"); diff --git a/lib/funcs/utili.dart b/lib/funcs/utili.dart index 51191ad..d1b0bf7 100644 --- a/lib/funcs/utili.dart +++ b/lib/funcs/utili.dart @@ -124,7 +124,10 @@ int calculateButtonBoxLayout(List possible, double width){ } } -Future extractTarBz2(String inputPath, String outputDir) async { +@pragma('vm:entry-point') +void extractTarBz2((String inputPath, String outputPath) args) async { + final inputPath = args.$1; + final outputDir = args.$2; final bytes = await io.File(inputPath).readAsBytes(); // 解压 bz2 @@ -136,7 +139,7 @@ Future extractTarBz2(String inputPath, String outputDir) async { // 解出文件 for (final file in tarArchive.files) { - final filePath = '$outputDir/${io.Platform.pathSeparator}${file.name}'; + final filePath = '$outputDir${io.Platform.pathSeparator}${file.name}'; if (file.isFile) { final outFile = io.File(filePath); await outFile.create(recursive: true); diff --git a/lib/main.dart b/lib/main.dart index cc458b0..84248d9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -258,6 +258,13 @@ class _MyHomePageState extends State { ); } + @override + void dispose(){ + _pageController.dispose(); + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.fine("构建 MyHomePage"); diff --git a/lib/oss_licenses.dart b/lib/oss_licenses.dart index 5381783..21294cb 100644 --- a/lib/oss_licenses.dart +++ b/lib/oss_licenses.dart @@ -94,6 +94,8 @@ const allDependencies = [ _node_preamble, _objective_c, _package_config, + _package_info_plus, + _package_info_plus_platform_interface, _pana, _path, _path_provider, @@ -163,6 +165,8 @@ const allDependencies = [ _uuid, _vector_math, _vm_service, + _wakelock_plus, + _wakelock_plus_platform_interface, _watcher, _web, _web_socket, @@ -210,7 +214,8 @@ const dependencies = [ _qr_flutter, _mobile_scanner, _cupertino_icons, - _bk_tree + _bk_tree, + _wakelock_plus ]; /// Direct `dev_dependencies`. @@ -2232,13 +2237,13 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', ); -/// flutter 3.41.4 +/// flutter 3.41.6 const _flutter = Package( name: 'flutter', description: 'A framework for writing Flutter applications', homepage: 'https://flutter.dev', authors: [], - version: '3.41.4', + version: '3.41.6', spdxIdentifiers: ['BSD-3-Clause'], isMarkdown: false, isSdk: true, @@ -4921,6 +4926,90 @@ met: contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', + ); + +/// package_info_plus 9.0.1 +const _package_info_plus = Package( + name: 'package_info_plus', + description: 'Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.', + homepage: 'https://github.com/fluttercommunity/plus_plugins', + repository: 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/package_info_plus/package_info_plus', + authors: [], + version: '9.0.1', + spdxIdentifiers: ['BSD-3-Clause'], + isMarkdown: false, + isSdk: false, + dependencies: [PackageRef('ffi'), PackageRef('flutter'), PackageRef('flutter_web_plugins'), PackageRef('http'), PackageRef('meta'), PackageRef('path'), PackageRef('package_info_plus_platform_interface'), PackageRef('web'), PackageRef('win32'), PackageRef('clock')], + devDependencies: [PackageRef('flutter_lints'), PackageRef('flutter_test'), PackageRef('test')], + license: '''Copyright 2017 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', + ); + +/// package_info_plus_platform_interface 3.2.1 +const _package_info_plus_platform_interface = Package( + name: 'package_info_plus_platform_interface', + description: 'A common platform interface for the package_info_plus plugin.', + homepage: 'https://github.com/fluttercommunity/plus_plugins', + repository: 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/', + authors: [], + version: '3.2.1', + spdxIdentifiers: ['BSD-3-Clause'], + isMarkdown: false, + isSdk: false, + dependencies: [PackageRef('flutter'), PackageRef('meta'), PackageRef('plugin_platform_interface')], + devDependencies: [PackageRef('flutter_test'), PackageRef('flutter_lints')], + license: '''Copyright 2017 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -39942,6 +40031,92 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', ); +/// wakelock_plus 1.5.1 +const _wakelock_plus = Package( + name: 'wakelock_plus', + description: 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, Linux, and web.', + repository: 'https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus', + authors: [], + version: '1.5.1', + spdxIdentifiers: ['BSD-3-Clause'], + isMarkdown: false, + isSdk: false, + dependencies: [PackageRef('flutter'), PackageRef('flutter_web_plugins'), PackageRef('meta'), PackageRef('wakelock_plus_platform_interface'), PackageRef('win32'), PackageRef('dbus'), PackageRef('package_info_plus'), PackageRef('web')], + devDependencies: [PackageRef('flutter_test'), PackageRef('flutter_lints')], + license: '''BSD 3-Clause License + +Copyright (c) 2020-2023, creativecreatorormaybenot +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', + ); + +/// wakelock_plus_platform_interface 1.4.0 +const _wakelock_plus_platform_interface = Package( + name: 'wakelock_plus_platform_interface', + description: 'A common platform interface for the wakelock_plus plugin used by the different platform implementations.', + repository: 'https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus_platform_interface', + authors: [], + version: '1.4.0', + spdxIdentifiers: ['BSD-3-Clause'], + isMarkdown: false, + isSdk: false, + dependencies: [PackageRef('flutter'), PackageRef('plugin_platform_interface'), PackageRef('meta')], + devDependencies: [PackageRef('flutter_test'), PackageRef('flutter_lints')], + license: '''BSD 3-Clause License + +Copyright (c) 2020-2023, creativecreatorormaybenot +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''', + ); + /// watcher 1.2.1 const _watcher = Package( name: 'watcher', @@ -40572,7 +40747,7 @@ const _arabic_learning = Package( spdxIdentifiers: ['AGPL-3.0'], isMarkdown: false, isSdk: false, - dependencies: [PackageRef('flutter'), PackageRef('window_manager'), PackageRef('path_provider'), PackageRef('provider'), PackageRef('file_picker'), PackageRef('flutter_tts'), PackageRef('just_audio'), PackageRef('just_audio_windows'), PackageRef('flutter_launcher_icons'), PackageRef('shared_preferences'), PackageRef('url_launcher'), PackageRef('sherpa_onnx'), PackageRef('archive'), PackageRef('dio'), PackageRef('fsrs'), PackageRef('idb_shim'), PackageRef('flutter_markdown_plus'), PackageRef('webdav_client'), PackageRef('logging'), PackageRef('flutter_local_notifications'), PackageRef('workmanager'), PackageRef('flutter_webrtc'), PackageRef('network_info_plus'), PackageRef('crypto'), PackageRef('qr_flutter'), PackageRef('mobile_scanner'), PackageRef('cupertino_icons'), PackageRef('bk_tree')], + dependencies: [PackageRef('flutter'), PackageRef('window_manager'), PackageRef('path_provider'), PackageRef('provider'), PackageRef('file_picker'), PackageRef('flutter_tts'), PackageRef('just_audio'), PackageRef('just_audio_windows'), PackageRef('flutter_launcher_icons'), PackageRef('shared_preferences'), PackageRef('url_launcher'), PackageRef('sherpa_onnx'), PackageRef('archive'), PackageRef('dio'), PackageRef('fsrs'), PackageRef('idb_shim'), PackageRef('flutter_markdown_plus'), PackageRef('webdav_client'), PackageRef('logging'), PackageRef('flutter_local_notifications'), PackageRef('workmanager'), PackageRef('flutter_webrtc'), PackageRef('network_info_plus'), PackageRef('crypto'), PackageRef('qr_flutter'), PackageRef('mobile_scanner'), PackageRef('cupertino_icons'), PackageRef('bk_tree'), PackageRef('wakelock_plus')], devDependencies: [PackageRef('flutter_test'), PackageRef('flutter_lints'), PackageRef('change_app_package_name'), PackageRef('dart_pubspec_licenses')], license: '''GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 diff --git a/lib/pages/setting_page.dart b/lib/pages/setting_page.dart index 085349d..ce0b0b6 100644 --- a/lib/pages/setting_page.dart +++ b/lib/pages/setting_page.dart @@ -221,7 +221,7 @@ class _SettingPage extends State { ), onPressed: () async { context.read().uiLogger.info("选择手动导入单词"); - FilePickerResult? result = await FilePicker.platform.pickFiles( + FilePickerResult? result = await FilePicker.pickFiles( allowMultiple: false, type: FileType.custom, allowedExtensions: ['json'], diff --git a/lib/sub_pages_builder/learning_pages/fsrs_pages.dart b/lib/sub_pages_builder/learning_pages/fsrs_pages.dart index ae2c50f..4b16bbd 100644 --- a/lib/sub_pages_builder/learning_pages/fsrs_pages.dart +++ b/lib/sub_pages_builder/learning_pages/fsrs_pages.dart @@ -602,6 +602,14 @@ class _FSRSLearningPageState extends State { super.initState(); } + @override + void dispose() { + controllerHor.dispose(); + controllerLearning.dispose(); + controllerQuestions.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { MediaQueryData mediaQuery = MediaQuery.of(context); diff --git a/lib/sub_pages_builder/learning_pages/learning_pages_build.dart b/lib/sub_pages_builder/learning_pages/learning_pages_build.dart index 41c61e4..f81d54c 100644 --- a/lib/sub_pages_builder/learning_pages/learning_pages_build.dart +++ b/lib/sub_pages_builder/learning_pages/learning_pages_build.dart @@ -84,6 +84,12 @@ class _InLearningPageState extends State { super.initState(); } + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建 InLearningPage"); @@ -621,6 +627,12 @@ class _WordCardOverViewPage extends State { final TextEditingController searchController = TextEditingController(); bool inSearch = false; + @override + void dispose() { + searchController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建 WordCardOverViewPage: inSearch{$inSearch}"); @@ -781,6 +793,13 @@ class _WordCardOverViewLayout extends State { bool allowJsonScorll = true; bool allowClassScorll = false; + @override + void dispose(){ + jsonController.dispose(); + classController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { MediaQueryData mediaQuery = MediaQuery.of(context); diff --git a/lib/sub_pages_builder/setting_pages/debug_page.dart b/lib/sub_pages_builder/setting_pages/debug_page.dart index 8d90a7d..eaf24df 100644 --- a/lib/sub_pages_builder/setting_pages/debug_page.dart +++ b/lib/sub_pages_builder/setting_pages/debug_page.dart @@ -15,6 +15,12 @@ class DebugPage extends StatefulWidget { class _DebugPage extends State { ScrollController controller = ScrollController(); + @override + void dispose(){ + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建 DebugPage"); diff --git a/lib/sub_pages_builder/setting_pages/model_download_page.dart b/lib/sub_pages_builder/setting_pages/model_download_page.dart index 425c90f..5cfaa76 100644 --- a/lib/sub_pages_builder/setting_pages/model_download_page.dart +++ b/lib/sub_pages_builder/setting_pages/model_download_page.dart @@ -3,6 +3,7 @@ import 'package:arabic_learning/funcs/utili.dart'; import 'package:arabic_learning/vars/global.dart'; import 'package:arabic_learning/vars/license_storage.dart'; import 'package:arabic_learning/vars/statics_var.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; @@ -26,7 +27,7 @@ class _ModelDownload extends State { @override Widget build(BuildContext context) { - context.read().uiLogger.info("构建 ModelDownload"); + // context.read().uiLogger.info("构建 ModelDownload"); return Scaffold( appBar: AppBar( title: const Text('模型下载'), @@ -76,7 +77,20 @@ class _ModelDownload extends State { setState(() { progress = 3; }); - await extractTarBz2('${basePath.path}/arabicLearning/tts/temp.tar.bz2', "${basePath.path}/arabicLearning/tts/model/"); + try{ + final String inputPath = '${basePath.path}/arabicLearning/tts/temp.tar.bz2'; + final String outputPath = "${basePath.path}/arabicLearning/tts/model/"; + await compute(extractTarBz2, (inputPath, outputPath)); + } catch (e) { + if(!context.mounted) return; + context.read().uiLogger.severe("解压发生错误: $e"); + alart(context, "解压发生错误: $e"); + setState(() { + progress = 0; + isDownloading = false; + }); + return; + } if(!context.mounted) return; AppData().loadTTS(AppData().config.audio.playRate); context.read().uiLogger.info("模型下载完成"); diff --git a/lib/sub_pages_builder/setting_pages/sync_page.dart b/lib/sub_pages_builder/setting_pages/sync_page.dart index bea225d..226ea07 100644 --- a/lib/sub_pages_builder/setting_pages/sync_page.dart +++ b/lib/sub_pages_builder/setting_pages/sync_page.dart @@ -199,7 +199,7 @@ class _DataSyncPage extends State { ElevatedButton( onPressed: () async { try{ - if(await FilePicker.platform.saveFile( + if(await FilePicker.saveFile( dialogTitle: "导出数据", lockParentWindow: true, fileName: "export.json", @@ -240,7 +240,7 @@ class _DataSyncPage extends State { ElevatedButton( onPressed: () async { context.read().uiLogger.info("导入软件数据"); - FilePickerResult? result = await FilePicker.platform.pickFiles( + FilePickerResult? result = await FilePicker.pickFiles( allowMultiple: false, type: FileType.custom, allowedExtensions: ['json'], @@ -354,7 +354,12 @@ Future popAccountSetting(BuildContext context) async { child: Text("清空"), ), ElevatedButton( - onPressed: () => Navigator.pop(context), + onPressed: () { + uriController.dispose(); + accountController.dispose(); + passwdController.dispose(); + Navigator.pop(context); + }, child: Text("取消"), ), ElevatedButton( @@ -376,6 +381,9 @@ Future popAccountSetting(BuildContext context) async { ) ); context.read().updateSetting(); + uriController.dispose(); + accountController.dispose(); + passwdController.dispose(); Navigator.pop(context); }, child: Text("确认") diff --git a/lib/sub_pages_builder/test_pages/listening_test_page.dart b/lib/sub_pages_builder/test_pages/listening_test_page.dart index c421d77..af2178e 100644 --- a/lib/sub_pages_builder/test_pages/listening_test_page.dart +++ b/lib/sub_pages_builder/test_pages/listening_test_page.dart @@ -6,6 +6,7 @@ import 'package:arabic_learning/vars/statics_var.dart'; import 'package:arabic_learning/vars/global.dart'; import 'package:arabic_learning/funcs/ui.dart'; import 'package:arabic_learning/funcs/utili.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; class ForeListeningSettingPage extends StatefulWidget { const ForeListeningSettingPage({super.key}); @@ -247,6 +248,19 @@ class _MainListeningPageState extends State { // 1: 播放中 // 2: 听写完成 // 3: 答案页面 + + @override + void initState() { + WakelockPlus.enable(); + super.initState(); + } + + @override + void dispose() { + WakelockPlus.disable(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建 MainListeningPage"); diff --git a/lib/sub_pages_builder/test_pages/local_pk_page.dart b/lib/sub_pages_builder/test_pages/local_pk_page.dart index a7390c9..157adec 100644 --- a/lib/sub_pages_builder/test_pages/local_pk_page.dart +++ b/lib/sub_pages_builder/test_pages/local_pk_page.dart @@ -37,6 +37,13 @@ class _LocalPKSelectPage extends State { ); } + @override + void dispose() { + connectpwdController.dispose(); + scannerController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建局域网联机主页面"); @@ -155,6 +162,12 @@ class _LocalPKPage extends State { super.initState(); } + @override + void dispose() { + pageController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { if(context.read().pageController == null) { @@ -212,6 +225,7 @@ class _ServerHostWatingPage extends State { @override void dispose() { scannerController.dispose(); + connectpwdController.dispose(); super.dispose(); } @@ -524,6 +538,12 @@ class _PKOngoingPage extends State { super.initState(); } + @override + void dispose() { + pageController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { context.read().uiLogger.info("构建局域网联机对局页面"); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 4c260d1..a7163c5 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + jni sherpa_onnx_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 42127b8..d90e011 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -13,9 +13,11 @@ import flutter_webrtc import just_audio import mobile_scanner import network_info_plus +import package_info_plus import screen_retriever_macos import shared_preferences_foundation import url_launcher_macos +import wakelock_plus import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -27,8 +29,10 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin")) MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 20274ba..81b20e0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,18 +37,18 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.13.1" audio_session: dependency: transitive description: name: audio_session - sha256: "8f96a7fecbb718cb093070f868b4cdcb8a9b1053dce342ff8ab2fde10eb9afb7" + sha256: "7217b229db57cc4dc577a8abb56b7429a5a212b978517a5be578704bfe5e568b" url: "https://pub.dev" source: hosted - version: "0.2.2" + version: "0.2.3" bk_tree: dependency: "direct main" description: @@ -173,10 +173,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" url: "https://pub.dev" source: hosted - version: "1.0.8" + version: "1.0.9" dart_pubspec_licenses: dependency: "direct dev" description: @@ -189,10 +189,10 @@ packages: dependency: transitive description: name: dart_webrtc - sha256: "4ed7b9fa9924e5a81eb39271e2c2356739dd1039d60a13b86ba6c5f448625086" + sha256: f6d615bddea5e458ce180a914f3055c234ffb52fb7397a51b3491e76d6d7edb2 url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.8.1" dbus: dependency: transitive description: @@ -245,10 +245,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "57d9a1dd5063f85fa3107fb42d1faffda52fdc948cefd5fe5ea85267a5fc7343" + sha256: f13a03000d942e476bc1ff0a736d2e9de711d2f89a95cd4c1d88f861c3348387 url: "https://pub.dev" source: hosted - version: "10.3.10" + version: "11.0.2" fixnum: dependency: transitive description: @@ -322,10 +322,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1 + sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0" url: "https://pub.dev" source: hosted - version: "2.0.33" + version: "2.0.34" flutter_test: dependency: "direct dev" description: flutter @@ -348,10 +348,10 @@ packages: dependency: "direct main" description: name: flutter_webrtc - sha256: c549ea8ffb20167110ad0a28e5f17a2650b5bea8837d984898cd9b0ffd5fa78b + sha256: c7b0a67ca2c878575fc5c146d801cd874f58f5f1ef5fa6e8eb0c93d413beb948 url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.4.1" frontend_server_client: dependency: transitive description: @@ -420,10 +420,10 @@ packages: dependency: "direct main" description: name: idb_shim - sha256: "921301da0a735f336a28fc35c3abdbd4498895cc205fa1ea9f7e785e7d854ceb" + sha256: "6cd94b71a33f1223b01ea2b359c3a6fde5980872b23b31d176a64c74d4dede57" url: "https://pub.dev" source: hosted - version: "2.8.2+4" + version: "2.8.5+2" image: dependency: transitive description: @@ -440,6 +440,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + jni: + dependency: transitive + description: + name: jni + sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f + url: "https://pub.dev" + source: hosted + version: "1.0.0" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" js: dependency: transitive description: @@ -484,10 +500,10 @@ packages: dependency: "direct main" description: name: just_audio_windows - sha256: b1ba5305d841c0e3883644e20fc11aaa23f28cfdd43ec20236d1e119a402ef29 + sha256: "7d80dfa02a2189f1c26673a56f4d8584a306d3f22735302be6111e9578a40318" url: "https://pub.dev" source: hosted - version: "0.2.2" + version: "0.2.3" leak_tracker: dependency: transitive description: @@ -524,10 +540,10 @@ packages: dependency: transitive description: name: logger - sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3 + sha256: "25aee487596a6257655a1e091ec2ae66bc30e7af663592cc3a27e6591e05035c" url: "https://pub.dev" source: hosted - version: "2.6.2" + version: "2.7.0" logging: dependency: "direct main" description: @@ -540,10 +556,10 @@ packages: dependency: transitive description: name: markdown - sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1" + sha256: ee85086ad7698b42522c6ad42fe195f1b9898e4d974a1af4576c1a3a176cada9 url: "https://pub.dev" source: hosted - version: "7.3.0" + version: "7.3.1" matcher: dependency: transitive description: @@ -588,10 +604,10 @@ packages: dependency: transitive description: name: native_toolchain_c - sha256: "92b2ca62c8bd2b8d2f267cdfccf9bfbdb7322f778f8f91b3ce5b5cda23a3899f" + sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572" url: "https://pub.dev" source: hosted - version: "0.17.5" + version: "0.17.6" nested: dependency: transitive description: @@ -648,14 +664,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" + package_info_plus: + dependency: transitive + description: + name: package_info_plus + sha256: "468c26b4254ab01979fa5e4a98cb343ea3631b9acee6f21028997419a80e1a20" + url: "https://pub.dev" + source: hosted + version: "9.0.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" + url: "https://pub.dev" + source: hosted + version: "3.2.1" pana: dependency: transitive description: name: pana - sha256: d7bd85f18a14909f0baab69a13895dc4ff163be51c9884f73a506982adeac57d + sha256: "847ee5df6ac13fdc6c53d641095de1b25886c973d0b0f0469c73521ebe4602fa" url: "https://pub.dev" source: hosted - version: "0.23.10" + version: "0.23.12" path: dependency: transitive description: @@ -676,10 +708,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" url: "https://pub.dev" source: hosted - version: "2.2.22" + version: "2.3.1" path_provider_foundation: dependency: transitive description: @@ -868,18 +900,18 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64" + sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf url: "https://pub.dev" source: hosted - version: "2.5.4" + version: "2.5.5" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "8374d6200ab33ac99031a852eba4c8eb2170c4bf20778b3e2c9eccb45384fb41" + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 url: "https://pub.dev" source: hosted - version: "2.4.21" + version: "2.4.23" shared_preferences_foundation: dependency: transitive description: @@ -900,10 +932,10 @@ packages: dependency: transitive description: name: shared_preferences_platform_interface - sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" shared_preferences_web: dependency: transitive description: @@ -956,50 +988,50 @@ packages: dependency: "direct main" description: name: sherpa_onnx - sha256: "3e864a08018656f1c51d17a0aa43d021a2f78a7bb5cff15476d5a0dc4dff2956" + sha256: c10a1052bf03b9e68562e5be7d3a60568738c8356f3607012f0260f88ea11f08 url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.36" sherpa_onnx_android: dependency: transitive description: name: sherpa_onnx_android - sha256: bc690be549b33ff0bc5d518ca9b4df1013a175ef84c25646298d1bedd3a6e305 + sha256: "03a70665e83c026ccf4d853fe87d011321bc66810c5ea108ea08a128f95d862a" url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.36" sherpa_onnx_ios: dependency: transitive description: name: sherpa_onnx_ios - sha256: "4f0bba765dafd9c9062a3be062aa11f7a012a0b34964244e3588c824d5fd6bbc" + sha256: d00ae34a1b0da6f05b7caffc2eb72edf5766bd538b6b1b68edeba8efc6798332 url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.37" sherpa_onnx_linux: dependency: transitive description: name: sherpa_onnx_linux - sha256: bcad6925062f7a79a4f3b4b672d2485f5b02074e31d5b7f0a4f1ddf718a8a821 + sha256: "55cf0071730f0c1f9aa1f8ae8aa1606719a47d899a2e1e1ec3336bc6c3d8cfab" url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.37" sherpa_onnx_macos: dependency: transitive description: name: sherpa_onnx_macos - sha256: d6718808d4384e2babca6718b9bac668e98ed8d00a1492ac4d09ecf2b406f6e6 + sha256: cd2f5310d3be0a72f616857ac5b1ed4183bb4a94ca9f1b4920362d80571614f2 url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.37" sherpa_onnx_windows: dependency: transitive description: name: sherpa_onnx_windows - sha256: ef6bc7a4c313d8ca710513a206fb650c4527e955068d8b4137b5a846f4809ead + sha256: b793d42bbc5ac48c0bb78170ac8c626397d45eb9d0f1aa9b431bec15ac651f66 url: "https://pub.dev" source: hosted - version: "1.12.28" + version: "1.12.37" sky_engine: dependency: transitive description: flutter @@ -1121,10 +1153,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611" + sha256: "3bb000251e55d4a209aa0e2e563309dc9bb2befea2295fd0cec1f51760aac572" url: "https://pub.dev" source: hosted - version: "6.3.28" + version: "6.3.29" url_launcher_ios: dependency: transitive description: @@ -1197,6 +1229,22 @@ packages: url: "https://pub.dev" source: hosted version: "15.0.2" + wakelock_plus: + dependency: "direct main" + description: + name: wakelock_plus + sha256: "8b12256f616346910c519a35606fb69b1fe0737c06b6a447c6df43888b097f39" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + wakelock_plus_platform_interface: + dependency: transitive + description: + name: wakelock_plus_platform_interface + sha256: "24b84143787220a403491c2e5de0877fbbb87baf3f0b18a2a988973863db4b03" + url: "https://pub.dev" + source: hosted + version: "1.4.0" watcher: dependency: transitive description: @@ -1249,10 +1297,10 @@ packages: dependency: transitive description: name: webrtc_interface - sha256: ad0e5786b2acd3be72a3219ef1dde9e1cac071cf4604c685f11b61d63cdd6eb3 + sha256: c6f100eac5057d9a817a60473126f9828c796d42884d498af4f339c97b21014f url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.5.1" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index e304e8d..4c4a5cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,7 +33,7 @@ dependencies: window_manager: ^0.5.1 #no support [android,iOS,Web] acceptable path_provider: ^2.1.5 #no support [Web] UNacceptable provider: ^6.0.1 - file_picker: ^10.3.3 #no completely support [Web] UNacceptable + file_picker: ^11.0.2 #no completely support [Web] UNacceptable flutter_tts: ^4.2.5 just_audio: ^0.10.5 just_audio_windows: ^0.2.2 #just_audio's windows addon @@ -57,6 +57,7 @@ dependencies: mobile_scanner: ^7.2.0 cupertino_icons: ^1.0.8 bk_tree: ^0.1.2 + wakelock_plus: ^1.5.1 dev_dependencies: flutter_test: @@ -69,7 +70,7 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^6.0.0 change_app_package_name: ^1.1.0 - dart_pubspec_licenses: ^3.0.15 + dart_pubspec_licenses: ^3.2.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f70a832..09e7c31 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -13,6 +13,7 @@ list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST flutter_local_notifications_windows + jni sherpa_onnx_windows )