diff --git a/lib/data/provider/systemd.dart b/lib/data/provider/systemd.dart index e619e5183..e55d7fa7c 100644 --- a/lib/data/provider/systemd.dart +++ b/lib/data/provider/systemd.dart @@ -19,6 +19,11 @@ final class SystemdProvider { final isBusy = false.vn; final units = [].vn; + void dispose() { + isBusy.dispose(); + units.dispose(); + } + Future getUnits() async { isBusy.value = true; diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index 74833d148..feac52f20 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -28,6 +28,13 @@ final class _BackupPageState extends State final icloudLoading = false.vn; final webdavLoading = false.vn; + @override + void dispose() { + icloudLoading.dispose(); + webdavLoading.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/view/page/container.dart b/lib/view/page/container.dart index 328672853..7c3920e7b 100644 --- a/lib/view/page/container.dart +++ b/lib/view/page/container.dart @@ -38,6 +38,7 @@ class _ContainerPageState extends State { void dispose() { super.dispose(); _textController.dispose(); + _container.dispose(); } @override diff --git a/lib/view/page/editor.dart b/lib/view/page/editor.dart index 04f5629ce..692defea3 100644 --- a/lib/view/page/editor.dart +++ b/lib/view/page/editor.dart @@ -50,6 +50,13 @@ class _EditorPageState extends State { String? _langCode; + @override + void dispose() { + super.dispose(); + _controller.dispose(); + _focusNode.dispose(); + } + @override void initState() { super.initState(); @@ -97,13 +104,6 @@ class _EditorPageState extends State { _focusNode.requestFocus(); } - @override - void dispose() { - _controller.dispose(); - _focusNode.dispose(); - super.dispose(); - } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/home/home.dart b/lib/view/page/home/home.dart index 7cde7deda..e74b2ccd7 100644 --- a/lib/view/page/home/home.dart +++ b/lib/view/page/home/home.dart @@ -31,6 +31,18 @@ class _HomePageState extends State bool _switchingPage = false; bool _shouldAuth = false; + @override + void dispose() { + super.dispose(); + WidgetsBinding.instance.removeObserver(this); + ServerProvider.closeServer(); + _pageController.dispose(); + WakelockPlus.disable(); + + _selectIndex.dispose(); + _isLandscape.dispose(); + } + @override void initState() { super.initState(); @@ -53,15 +65,6 @@ class _HomePageState extends State MediaQuery.of(context).orientation == Orientation.landscape; } - @override - void dispose() { - super.dispose(); - WidgetsBinding.instance.removeObserver(this); - ServerProvider.closeServer(); - _pageController.dispose(); - WakelockPlus.disable(); - } - @override void didChangeAppLifecycleState(AppLifecycleState state) { super.didChangeAppLifecycleState(state); diff --git a/lib/view/page/iperf.dart b/lib/view/page/iperf.dart index b13b569b0..2a75e88aa 100644 --- a/lib/view/page/iperf.dart +++ b/lib/view/page/iperf.dart @@ -16,6 +16,13 @@ class _IPerfPageState extends State { final _hostCtrl = TextEditingController(); final _portCtrl = TextEditingController(); + @override + void dispose() { + super.dispose(); + _hostCtrl.dispose(); + _portCtrl.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/ping.dart b/lib/view/page/ping.dart index 8539b2b3b..a472878cd 100644 --- a/lib/view/page/ping.dart +++ b/lib/view/page/ping.dart @@ -23,12 +23,6 @@ class _PingPageState extends State final _results = ValueNotifier([]); bool get isInit => _results.value.isEmpty; - @override - void initState() { - super.initState(); - _textEditingController = TextEditingController(text: ''); - } - @override void dispose() { super.dispose(); @@ -36,6 +30,12 @@ class _PingPageState extends State _results.dispose(); } + @override + void initState() { + super.initState(); + _textEditingController = TextEditingController(text: ''); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/view/page/private_key/edit.dart b/lib/view/page/private_key/edit.dart index 2e31022b2..321a25aa4 100644 --- a/lib/view/page/private_key/edit.dart +++ b/lib/view/page/private_key/edit.dart @@ -34,6 +34,18 @@ class _PrivateKeyEditPageState extends State { final _loading = ValueNotifier(null); + @override + void dispose() { + super.dispose(); + _nameController.dispose(); + _keyController.dispose(); + _pwdController.dispose(); + _nameNode.dispose(); + _keyNode.dispose(); + _pwdNode.dispose(); + _loading.dispose(); + } + @override void initState() { super.initState(); @@ -51,17 +63,6 @@ class _PrivateKeyEditPageState extends State { } } - @override - void dispose() { - super.dispose(); - _nameController.dispose(); - _keyController.dispose(); - _pwdController.dispose(); - _nameNode.dispose(); - _keyNode.dispose(); - _pwdNode.dispose(); - } - @override void didChangeDependencies() { super.didChangeDependencies(); diff --git a/lib/view/page/process.dart b/lib/view/page/process.dart index 6c73f902b..16a9e9ea5 100644 --- a/lib/view/page/process.dart +++ b/lib/view/page/process.dart @@ -34,6 +34,12 @@ class _ProcessPageState extends State { ProcSortMode _procSortMode = ProcSortMode.cpu; List _sortModes = List.from(ProcSortMode.values); + @override + void dispose() { + super.dispose(); + _timer.cancel(); + } + @override void initState() { super.initState(); @@ -75,12 +81,6 @@ class _ProcessPageState extends State { } } - @override - void dispose() { - super.dispose(); - _timer.cancel(); - } - @override Widget build(BuildContext context) { final actions = [ diff --git a/lib/view/page/pve.dart b/lib/view/page/pve.dart index 230637440..10e33c436 100644 --- a/lib/view/page/pve.dart +++ b/lib/view/page/pve.dart @@ -29,6 +29,13 @@ final class _PvePageState extends State { late MediaQueryData _media; Timer? _timer; + @override + void dispose() { + super.dispose(); + _timer?.cancel(); + _pve.dispose(); + } + @override void didChangeDependencies() { super.didChangeDependencies(); @@ -42,13 +49,6 @@ final class _PvePageState extends State { _afterInit(); } - @override - void dispose() { - super.dispose(); - _timer?.cancel(); - _pve.dispose(); - } - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/server/detail/view.dart b/lib/view/page/server/detail/view.dart index 984b00458..7915aa439 100644 --- a/lib/view/page/server/detail/view.dart +++ b/lib/view/page/server/detail/view.dart @@ -62,6 +62,12 @@ class _ServerDetailPageState extends State late final _collapse = _settings.collapseUIDefault.fetch(); late final _textFactor = TextScaler.linear(_settings.textFactor.fetch()); + @override + void dispose() { + super.dispose(); + _netSortType.dispose(); + } + @override void didChangeDependencies() { super.didChangeDependencies(); diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index dd6dc77a0..820eac898 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -72,12 +72,6 @@ class _ServerEditPageState extends State with AfterLayoutMixin { _portController.dispose(); _usernameController.dispose(); _passwordController.dispose(); - _nameFocus.dispose(); - _ipFocus.dispose(); - _alterUrlFocus.dispose(); - _portFocus.dispose(); - _usernameFocus.dispose(); - _pveAddrCtrl.dispose(); _preferTempDevCtrl.dispose(); _logoUrlCtrl.dispose(); _wolMacCtrl.dispose(); @@ -85,6 +79,21 @@ class _ServerEditPageState extends State with AfterLayoutMixin { _wolPwdCtrl.dispose(); _netDevCtrl.dispose(); _scriptDirCtrl.dispose(); + + _nameFocus.dispose(); + _ipFocus.dispose(); + _alterUrlFocus.dispose(); + _portFocus.dispose(); + _usernameFocus.dispose(); + _pveAddrCtrl.dispose(); + + _keyIdx.dispose(); + _autoConnect.dispose(); + _jumpServer.dispose(); + _pveIgnoreCert.dispose(); + _env.dispose(); + _customCmds.dispose(); + _tags.dispose(); } @override diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 55b3b5b9c..441718029 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -51,6 +51,15 @@ class _ServerPageState extends State final _scrollController = ScrollController(); final _autoHideKey = GlobalKey(); + @override + void dispose() { + super.dispose(); + _timer?.cancel(); + _scrollController.dispose(); + _autoHideKey.currentState?.dispose(); + _tag.dispose(); + } + @override void initState() { super.initState(); diff --git a/lib/view/page/server/top_bar.dart b/lib/view/page/server/top_bar.dart index d9806b8cd..737c50351 100644 --- a/lib/view/page/server/top_bar.dart +++ b/lib/view/page/server/top_bar.dart @@ -14,15 +14,34 @@ final class _TopBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only(left: 17), + padding: const EdgeInsets.only(left: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Center( - child: Text( - BuildData.name, - style: TextStyle(fontSize: 20), - textAlign: TextAlign.center, + Center( + child: InkWell( + borderRadius: BorderRadius.circular(13), + onTap: () => DebugPage.route.go( + context, + args: const DebugPageArgs(title: 'Logs(${BuildData.build})'), + ), + child: const Padding( + padding: EdgeInsets.symmetric(horizontal: 7), + child: Row( + children: [ + Text( + BuildData.name, + style: TextStyle(fontSize: 20), + textAlign: TextAlign.center, + ), + Icon( + Icons.keyboard_arrow_right, + color: Colors.grey, + size: 17, + ), + ], + ), + ), ), ), const SizedBox(width: 30), diff --git a/lib/view/page/setting/entry.dart b/lib/view/page/setting/entry.dart index 12e0eaed4..2399eab28 100644 --- a/lib/view/page/setting/entry.dart +++ b/lib/view/page/setting/entry.dart @@ -59,6 +59,12 @@ class _SettingsPageState extends State late final _tabCtrl = TabController(length: SettingsTabs.values.length, vsync: this); + @override + void dispose() { + super.dispose(); + _tabCtrl.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/setting/platform/ios.dart b/lib/view/page/setting/platform/ios.dart index a632108f4..5063aec25 100644 --- a/lib/view/page/setting/platform/ios.dart +++ b/lib/view/page/setting/platform/ios.dart @@ -18,6 +18,12 @@ class _IOSSettingsPageState extends State { final wc = WatchConnectivity(); + @override + void dispose() { + super.dispose(); + _pushToken.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/page/snippet/edit.dart b/lib/view/page/snippet/edit.dart index 64f29aa4a..c48ca4101 100644 --- a/lib/view/page/snippet/edit.dart +++ b/lib/view/page/snippet/edit.dart @@ -29,7 +29,10 @@ class _SnippetEditPageState extends State super.dispose(); _nameController.dispose(); _scriptController.dispose(); + _noteController.dispose(); _scriptNode.dispose(); + _autoRunOn.dispose(); + _tags.dispose(); } @override diff --git a/lib/view/page/snippet/list.dart b/lib/view/page/snippet/list.dart index 47136e78d..b0157f541 100644 --- a/lib/view/page/snippet/list.dart +++ b/lib/view/page/snippet/list.dart @@ -17,6 +17,12 @@ class _SnippetListPageState extends State with AutomaticKeepAliveClientMixin { final _tag = ''.vn; + @override + void dispose() { + super.dispose(); + _tag.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/view/page/ssh/page.dart b/lib/view/page/ssh/page.dart index 5b8304eae..1beb730e9 100644 --- a/lib/view/page/ssh/page.dart +++ b/lib/view/page/ssh/page.dart @@ -70,20 +70,20 @@ class SSHPageState extends State late SSHClient? _client = widget.spi.server?.value.client; Timer? _discontinuityTimer; - @override - void initState() { - super.initState(); - _initStoredCfg(); - _initVirtKeys(); - } - @override void dispose() { super.dispose(); _virtKeyLongPressTimer?.cancel(); _terminalController.dispose(); _discontinuityTimer?.cancel(); - if (!Stores.setting.generalWakeLock.fetch()) WakelockPlus.disable(); + WakelockPlus.disable(); + } + + @override + void initState() { + super.initState(); + _initStoredCfg(); + _initVirtKeys(); _setupDiscontinuityTimer(); } diff --git a/lib/view/page/ssh/tab.dart b/lib/view/page/ssh/tab.dart index d39484fdc..43a8f0e33 100644 --- a/lib/view/page/ssh/tab.dart +++ b/lib/view/page/ssh/tab.dart @@ -28,6 +28,14 @@ class _SSHTabPageState extends State final _fabVN = 0.vn; final _tabRN = RNode(); + @override + void dispose() { + super.dispose(); + _pageCtrl.dispose(); + _tabRN.dispose(); + _fabVN.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/view/page/storage/local.dart b/lib/view/page/storage/local.dart index 647383e0a..10de74a77 100644 --- a/lib/view/page/storage/local.dart +++ b/lib/view/page/storage/local.dart @@ -41,6 +41,12 @@ class _LocalFilePageState extends State final _sortType = _SortType.name.vn; bool get isPickFile => widget.args?.isPickFile ?? false; + @override + void dispose() { + super.dispose(); + _sortType.dispose(); + } + @override Widget build(BuildContext context) { super.build(context); diff --git a/lib/view/page/storage/sftp.dart b/lib/view/page/storage/sftp.dart index e16dde390..1cc2b6f41 100644 --- a/lib/view/page/storage/sftp.dart +++ b/lib/view/page/storage/sftp.dart @@ -42,6 +42,12 @@ class _SftpPageState extends State with AfterLayoutMixin { late final _client = widget.spi.server!.value.client!; final _sortOption = _SortOption().vn; + @override + void dispose() { + super.dispose(); + _sortOption.dispose(); + } + @override Widget build(BuildContext context) { final children = [ diff --git a/lib/view/page/systemd.dart b/lib/view/page/systemd.dart index bf2e4938e..4ae289543 100644 --- a/lib/view/page/systemd.dart +++ b/lib/view/page/systemd.dart @@ -33,6 +33,12 @@ final class SystemdPage extends StatefulWidget { final class _SystemdPageState extends State { late final _pro = SystemdProvider.init(widget.args.spi); + @override + void dispose() { + super.dispose(); + _pro.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold(