From 9ef59f4c123701c983d13e3e23e95c9dd703fd0c Mon Sep 17 00:00:00 2001 From: LollipopKit <2036293523@qq.com> Date: Sun, 21 Nov 2021 19:36:07 +0800 Subject: [PATCH] Fix: app update issue on MIUI --- lib/core/update.dart | 11 +++++++++-- lib/data/res/build_data.dart | 9 ++++----- pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/core/update.dart b/lib/core/update.dart index 6ee85fcf..acfc4825 100644 --- a/lib/core/update.dart +++ b/lib/core/update.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:r_upgrade/r_upgrade.dart'; import 'package:toolbox/core/utils.dart'; import 'package:toolbox/data/provider/app.dart'; import 'package:toolbox/data/res/build_data.dart'; @@ -41,6 +42,12 @@ Future doUpdate(BuildContext context, {bool force = false}) async { update.min > BuildData.build ? 'Your version is too old. \nPlease update to v1.0.${update.newest}.' : 'Update: v1.0.${update.newest} available. \n${update.changelog}', - 'Update', - () => openUrl(Platform.isAndroid ? update.android : update.ios)); + 'Update', () async { + if (Platform.isAndroid) { + await RUpgrade.upgrade(update.android, + fileName: update.android.split('/').last, isAutoRequestInstall: true); + } else if (Platform.isIOS) { + showSnackBar(context, const Text('Not support iOS now.')); + } + }); } diff --git a/lib/data/res/build_data.dart b/lib/data/res/build_data.dart index e199d42f..f830e2a8 100644 --- a/lib/data/res/build_data.dart +++ b/lib/data/res/build_data.dart @@ -2,9 +2,8 @@ class BuildData { static const String name = "ToolBox"; - static const int build = 61; - static const String engine = - "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (3 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n"; - static const String buildAt = "2021-11-05 12:58:33.427838"; - static const int modifications = 15; + static const int build = 63; + static const String engine = "Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 18116933e7 (5 weeks ago) • 2021-10-15 10:46:35 -0700\nEngine • revision d3ea636dc5\nTools • Dart 2.14.4\n"; + static const String buildAt = "2021-11-21 19:35:22.997443"; + static const int modifications = 4; } diff --git a/pubspec.lock b/pubspec.lock index 512923d6..89ee6901 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -363,6 +363,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.1" + r_upgrade: + dependency: "direct main" + description: + name: r_upgrade + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.6" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index c8ec248c..ad1c7fc4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: url: https://github.com/LollipopKit/circle_chart ref: main clipboard: ^0.1.3 + r_upgrade: ^0.3.6 dev_dependencies: