From 9cdfd86f707a8405b03e022e56e87fa71a1fee65 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Wed, 19 Apr 2023 20:58:29 +0800 Subject: [PATCH] replace: `context.pop` --- ios/Runner.xcodeproj/project.pbxproj | 12 +++--- lib/core/update.dart | 3 +- lib/core/utils/navigator.dart | 5 +-- lib/core/utils/ui.dart | 5 ++- lib/data/res/build_data.dart | 6 +-- lib/view/page/backup.dart | 6 ++- lib/view/page/docker.dart | 29 +++++++------- lib/view/page/home.dart | 5 ++- lib/view/page/pkg.dart | 11 +++--- lib/view/page/private_key/edit.dart | 5 ++- lib/view/page/server/edit.dart | 13 ++++--- lib/view/page/server/tab.dart | 5 ++- lib/view/page/sftp/downloaded.dart | 9 +++-- lib/view/page/sftp/view.dart | 56 ++++++++++++++-------------- lib/view/page/snippet/edit.dart | 5 ++- lib/view/page/ssh.dart | 3 +- make.dart | 2 + 17 files changed, 96 insertions(+), 84 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8b4016f4..e9b30864 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 268; + CURRENT_PROJECT_VERSION = 269; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -367,7 +367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.268; + MARKETING_VERSION = 1.0.269; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -490,7 +490,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 268; + CURRENT_PROJECT_VERSION = 269; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -498,7 +498,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.268; + MARKETING_VERSION = 1.0.269; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -515,7 +515,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 268; + CURRENT_PROJECT_VERSION = 269; DEVELOPMENT_TEAM = BA88US33G6; ENABLE_BITCODE = NO; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; @@ -523,7 +523,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.268; + MARKETING_VERSION = 1.0.269; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/lib/core/update.dart b/lib/core/update.dart index 032a5340..2e1d3f81 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:logging/logging.dart'; import 'package:r_upgrade/r_upgrade.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../data/provider/app.dart'; import '../data/res/build_data.dart'; @@ -85,7 +86,7 @@ Future _doUpdate(String url, BuildContext context, S s) async { } else { showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(s.ok), ) ]); diff --git a/lib/core/utils/navigator.dart b/lib/core/utils/navigator.dart index 34a46071..22e09794 100644 --- a/lib/core/utils/navigator.dart +++ b/lib/core/utils/navigator.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; - extension ContextX on BuildContext { void pop([T? result]) { - Navigator.of(this).pop(T); -} + Navigator.of(this).pop(T); + } } diff --git a/lib/core/utils/ui.dart b/lib/core/utils/ui.dart index c13d3363..6d5b3b9b 100644 --- a/lib/core/utils/ui.dart +++ b/lib/core/utils/ui.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../data/model/server/snippet.dart'; @@ -135,7 +136,7 @@ void showSnippetDialog( ), TextButton( onPressed: () { - Navigator.of(context).pop(); + context.pop(); AppRoute(const SnippetEditPage(), 'edit snippet').go(context); }, child: Text(s.addOne), @@ -156,7 +157,7 @@ void showSnippetDialog( [ TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); onSelected(snippet); }, child: Text(s.ok), diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index dcc24e41..d4e4d1d5 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,8 +2,8 @@ class BuildData { static const String name = "ServerBox"; - static const int build = 268; + static const int build = 269; static const String engine = "3.7.11"; - static const String buildAt = "2023-04-19 20:26:15.641670"; - static const int modifications = 4; + static const String buildAt = "2023-04-19 20:53:37.738261"; + static const int modifications = 15; } diff --git a/lib/view/page/backup.dart b/lib/view/page/backup.dart index 67f4b607..ae9db9b6 100644 --- a/lib/view/page/backup.dart +++ b/lib/view/page/backup.dart @@ -5,6 +5,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import 'package:toolbox/data/res/path.dart'; import '../../core/extension/colorx.dart'; @@ -145,7 +146,7 @@ class BackupPage extends StatelessWidget { Text(s.restoreSureWithDate(backup.date)), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(s.cancel), ), TextButton( @@ -162,6 +163,7 @@ class BackupPage extends StatelessWidget { for (final k in backup.dockerHosts.keys) { _dockerHosts.setDockerHost(k, backup.dockerHosts[k]!); } + context.pop(); showRoundDialog( context, s.attention, @@ -172,7 +174,7 @@ class BackupPage extends StatelessWidget { child: Text(s.restart), ), TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(s.cancel), ), ], diff --git a/lib/view/page/docker.dart b/lib/view/page/docker.dart index e304b8c6..06023cb6 100644 --- a/lib/view/page/docker.dart +++ b/lib/view/page/docker.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../core/utils/ui.dart'; import '../../data/model/docker/ps.dart'; @@ -50,7 +51,7 @@ class _DockerManagePageState extends State { final client = locator().getServer(widget.spi.id).client; if (client == null) { showSnackBar(context, Text(_s.noClient)); - Navigator.of(context).pop(); + context.pop(); return; } _docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id); @@ -119,12 +120,12 @@ class _DockerManagePageState extends State { ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); await _showAddCmdPreview( _buildAddCmd( imageCtrl.text.trim(), @@ -146,12 +147,12 @@ class _DockerManagePageState extends State { Text(cmd), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); final result = await _docker.run(cmd); if (result != null) { showSnackBar(context, Text(getErrMsg(result) ?? _s.unknownError)); @@ -187,13 +188,13 @@ class _DockerManagePageState extends State { if (_textController.text == '') { showRoundDialog(context, _s.attention, Text(_s.fieldMustNotEmpty), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ), ]); return; } - Navigator.of(context).pop(); + context.pop(); } Future onPwdRequest() async { @@ -213,8 +214,8 @@ class _DockerManagePageState extends State { [ TextButton( onPressed: () { - Navigator.of(context).pop(); - Navigator.of(context).pop(); + context.pop(); + context.pop(); }, child: Text(_s.cancel), ), @@ -294,12 +295,12 @@ class _DockerManagePageState extends State { Text(_s.sureDelete(e.repo)), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); final result = await _docker.run( 'docker rmi ${e.id} -f', ); @@ -375,12 +376,12 @@ class _DockerManagePageState extends State { onSubmitted: (value) { locator().setDockerHost(widget.spi.id, value.trim()); _docker.refresh(); - Navigator.of(context).pop(); + context.pop(); }, ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), ], @@ -478,7 +479,7 @@ class _DockerManagePageState extends State { [ TextButton( onPressed: () { - Navigator.of(context).pop(); + context.pop(); _docker.delete(dItem.containerId); }, child: Text(_s.ok), diff --git a/lib/view/page/home.dart b/lib/view/page/home.dart index b07f91b6..4728bea1 100644 --- a/lib/view/page/home.dart +++ b/lib/view/page/home.dart @@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:get_it/get_it.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import 'package:toolbox/data/provider/app.dart'; import 'package:toolbox/data/res/misc.dart'; @@ -253,7 +254,7 @@ class _MyHomePageState extends State child: Text(_s.feedback), ), TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.close), ) ], @@ -297,7 +298,7 @@ class _MyHomePageState extends State child: Text(_s.license), ), TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.close), ) ], diff --git a/lib/view/page/pkg.dart b/lib/view/page/pkg.dart index 21c152dd..8cc69ea6 100644 --- a/lib/view/page/pkg.dart +++ b/lib/view/page/pkg.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../data/model/pkg/upgrade_info.dart'; import '../../data/model/server/dist.dart'; @@ -51,7 +52,7 @@ class _PkgManagePageState extends State final si = locator().getServer(widget.spi.id); if (si.client == null) { showSnackBar(context, Text(_s.waitConnection)); - Navigator.of(context).pop(); + context.pop(); return; } @@ -76,14 +77,14 @@ class _PkgManagePageState extends State Text(_s.fieldMustNotEmpty), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ), ], ); return; } - Navigator.of(context).pop(); + context.pop(); } Future onPwdRequest() async { @@ -103,8 +104,8 @@ class _PkgManagePageState extends State [ TextButton( onPressed: () { - Navigator.of(context).pop(); - Navigator.of(context).pop(); + context.pop(); + context.pop(); }, child: Text(_s.cancel)), TextButton( diff --git a/lib/view/page/private_key/edit.dart b/lib/view/page/private_key/edit.dart index c2dac9d4..fa1b1aae 100644 --- a/lib/view/page/private_key/edit.dart +++ b/lib/view/page/private_key/edit.dart @@ -7,6 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:toolbox/core/extension/numx.dart'; import 'package:toolbox/core/utils/misc.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import 'package:toolbox/data/res/misc.dart'; import '../../../core/utils/server.dart'; @@ -68,7 +69,7 @@ class _PrivateKeyEditPageState extends State tooltip: _s.delete, onPressed: () { _provider.delInfo(widget.info!); - Navigator.of(context).pop(); + context.pop(); }, icon: const Icon(Icons.delete)) : const SizedBox() @@ -176,7 +177,7 @@ class _PrivateKeyEditPageState extends State } else { _provider.addInfo(info); } - Navigator.of(context).pop(); + context.pop(); }, child: const Icon(Icons.save), ), diff --git a/lib/view/page/server/edit.dart b/lib/view/page/server/edit.dart index f0e7fc90..9302ec67 100644 --- a/lib/view/page/server/edit.dart +++ b/lib/view/page/server/edit.dart @@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../../core/route.dart'; import '../../../core/utils/ui.dart'; @@ -74,8 +75,8 @@ class _ServerEditPageState extends State with AfterLayoutMixin { TextButton( onPressed: () { _serverProvider.delServer(widget.spi!.id); - Navigator.of(context).pop(); - Navigator.of(context).pop(); + context.pop(); + context.pop(); }, child: Text( _s.ok, @@ -83,7 +84,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { ), ), TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ) ], @@ -232,11 +233,11 @@ class _ServerEditPageState extends State with AfterLayoutMixin { Text(_s.sureNoPwd), [ TextButton( - onPressed: () => Navigator.of(context).pop(false), + onPressed: () => context.pop(false), child: Text(_s.ok), ), TextButton( - onPressed: () => Navigator.of(context).pop(true), + onPressed: () => context.pop(true), child: Text(_s.cancel), ) ], @@ -277,7 +278,7 @@ class _ServerEditPageState extends State with AfterLayoutMixin { _serverProvider.updateServer(widget.spi!, spi); } - Navigator.of(context).pop(); + context.pop(); }, ), ); diff --git a/lib/view/page/server/tab.dart b/lib/view/page/server/tab.dart index 330f9739..304b05e3 100644 --- a/lib/view/page/server/tab.dart +++ b/lib/view/page/server/tab.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:get_it/get_it.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../../core/route.dart'; import '../../../core/utils/ui.dart'; @@ -222,7 +223,7 @@ class _ServerPageState extends State [ TextButton( onPressed: () { - Navigator.of(context).pop(); + context.pop(); AppRoute(SSHPage(spi: spi), 'ssh page').go(context); }, child: Text(_s.ok), @@ -272,7 +273,7 @@ class _ServerPageState extends State Text(result ?? _s.error, style: textSize13), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ) ], diff --git a/lib/view/page/sftp/downloaded.dart b/lib/view/page/sftp/downloaded.dart index 45122c3e..f49790c1 100644 --- a/lib/view/page/sftp/downloaded.dart +++ b/lib/view/page/sftp/downloaded.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../../core/extension/numx.dart'; import '../../../core/extension/stringx.dart'; @@ -144,21 +145,21 @@ class _SFTPDownloadedPageState extends State { leading: const Icon(Icons.delete), title: Text(_s.delete), onTap: () { - Navigator.of(context).pop(); + context.pop(); showRoundDialog( context, _s.sureDelete(fileName), const SizedBox(), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () { file.deleteSync(); setState(() {}); - Navigator.of(context).pop(); + context.pop(); }, child: Text(_s.ok), ), @@ -177,7 +178,7 @@ class _SFTPDownloadedPageState extends State { ), [ TextButton( - onPressed: (() => Navigator.of(context).pop()), + onPressed: (() => context.pop()), child: Text(_s.close), ) ], diff --git a/lib/view/page/sftp/view.dart b/lib/view/page/sftp/view.dart index b317a8e8..7d392600 100644 --- a/lib/view/page/sftp/view.dart +++ b/lib/view/page/sftp/view.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:dartssh2/dartssh2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../../core/extension/numx.dart'; import '../../../core/extension/stringx.dart'; @@ -114,7 +115,7 @@ class _SFTPPageState extends State { ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.close), ) ], @@ -135,14 +136,13 @@ class _SFTPPageState extends State { labelText: _s.path, hintText: '/', ), - onSubmitted: (value) => - Navigator.of(context).pop(value), + onSubmitted: (value) => context.pop(value), ), ], ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ) ], @@ -280,7 +280,7 @@ class _SFTPPageState extends State { ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ) ], @@ -294,12 +294,12 @@ class _SFTPPageState extends State { Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); final remotePath = _getRemotePath(name); final local = '${(await sftpDir).path}$remotePath'; final pubKeyId = widget.spi.pubKeyId; @@ -315,7 +315,7 @@ class _SFTPPageState extends State { : locator().get(pubKeyId).privateKey, ); - Navigator.of(context).pop(); + context.pop(); }, child: Text(_s.download), ) @@ -324,7 +324,7 @@ class _SFTPPageState extends State { } void delete(BuildContext context, SftpName file) { - Navigator.of(context).pop(); + context.pop(); final isDir = file.attr.isDirectory; showRoundDialog( context, @@ -333,12 +333,12 @@ class _SFTPPageState extends State { '${_s.sureDelete(file.filename)}${isDir ? '\n${_s.sureDirEmpty}' : ''}'), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( onPressed: () async { - Navigator.of(context).pop(); + context.pop(); showRoundDialog(context, 'Waiting...', centerSizedLoading, [], barrierDismiss: false); final remotePath = _getRemotePath(file); @@ -348,16 +348,16 @@ class _SFTPPageState extends State { } else { await _status.client!.remove(remotePath); } - Navigator.of(context).pop(); + context.pop(); } catch (e) { - Navigator.of(context).pop(); + context.pop(); showRoundDialog( context, _s.attention, Text(e.toString()), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ) ], @@ -376,7 +376,7 @@ class _SFTPPageState extends State { } void mkdir(BuildContext context) { - Navigator.of(context).pop(); + context.pop(); final textController = TextEditingController(); showRoundDialog( context, @@ -389,7 +389,7 @@ class _SFTPPageState extends State { ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( @@ -401,7 +401,7 @@ class _SFTPPageState extends State { Text(_s.fieldMustNotEmpty), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ), ], @@ -410,7 +410,7 @@ class _SFTPPageState extends State { } _status.client! .mkdir('${_status.path!.path}/${textController.text}'); - Navigator.of(context).pop(); + context.pop(); listDir(); }, child: Text( @@ -423,7 +423,7 @@ class _SFTPPageState extends State { } void newFile(BuildContext context) { - Navigator.of(context).pop(); + context.pop(); final textController = TextEditingController(); showRoundDialog( context, @@ -436,7 +436,7 @@ class _SFTPPageState extends State { ), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.cancel), ), TextButton( @@ -448,7 +448,7 @@ class _SFTPPageState extends State { Text(_s.fieldMustNotEmpty), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ), ], @@ -458,7 +458,7 @@ class _SFTPPageState extends State { (await _status.client! .open('${_status.path!.path}/${textController.text}')) .writeBytes(Uint8List(0)); - Navigator.of(context).pop(); + context.pop(); listDir(); }, child: Text( @@ -471,7 +471,7 @@ class _SFTPPageState extends State { } void rename(BuildContext context, SftpName file) { - Navigator.of(context).pop(); + context.pop(); final textController = TextEditingController(); showRoundDialog( context, @@ -483,9 +483,7 @@ class _SFTPPageState extends State { ), ), [ - TextButton( - onPressed: () => Navigator.of(context).pop(), - child: Text(_s.cancel)), + TextButton(onPressed: () => context.pop(), child: Text(_s.cancel)), TextButton( onPressed: () async { if (textController.text == '') { @@ -495,7 +493,7 @@ class _SFTPPageState extends State { Text(_s.fieldMustNotEmpty), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ), ], @@ -503,7 +501,7 @@ class _SFTPPageState extends State { return; } await _status.client!.rename(file.filename, textController.text); - Navigator.of(context).pop(); + context.pop(); listDir(); }, child: Text( @@ -547,7 +545,7 @@ class _SFTPPageState extends State { Text(e.toString()), [ TextButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () => context.pop(), child: Text(_s.ok), ) ], diff --git a/lib/view/page/snippet/edit.dart b/lib/view/page/snippet/edit.dart index aa7b22b4..81d20439 100644 --- a/lib/view/page/snippet/edit.dart +++ b/lib/view/page/snippet/edit.dart @@ -1,6 +1,7 @@ import 'package:after_layout/after_layout.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import '../../../core/utils/ui.dart'; import '../../../data/model/server/snippet.dart'; @@ -49,7 +50,7 @@ class _SnippetEditPageState extends State ? IconButton( onPressed: () { _provider.del(widget.snippet!); - Navigator.of(context).pop(); + context.pop(); }, tooltip: _s.delete, icon: const Icon(Icons.delete)) @@ -93,7 +94,7 @@ class _SnippetEditPageState extends State } else { _provider.add(snippet); } - Navigator.of(context).pop(); + context.pop(); }, ), ); diff --git a/lib/view/page/ssh.dart b/lib/view/page/ssh.dart index 2bb436e0..63453705 100644 --- a/lib/view/page/ssh.dart +++ b/lib/view/page/ssh.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:provider/provider.dart'; +import 'package:toolbox/core/utils/navigator.dart'; import 'package:xterm/xterm.dart' hide TerminalColors; import '../../core/utils/platform.dart'; @@ -119,7 +120,7 @@ class _SSHPageState extends State { await session.done; if (mounted) { - Navigator.of(context).pop(); + context.pop(); } } diff --git a/make.dart b/make.dart index 7b360e39..545fbd33 100755 --- a/make.dart +++ b/make.dart @@ -196,6 +196,8 @@ void main(List args) async { final stopwatch = Stopwatch()..start(); await dartFormat(); await getGitCommitCount(); + // always change version to avoid dismatch version between different + // platforms await changeAppleVersion(); await updateBuildData(); if (args.length > 1) {