From eb157ce92fab8a084388c2cf930ccc19fb5a0530 Mon Sep 17 00:00:00 2001 From: Rounak Tadvi Date: Fri, 13 May 2022 21:14:11 +0530 Subject: [PATCH 1/4] fix(flutter-v2-embedding): fix flutter-v2-embedding issue --- .../android/app/src/main/AndroidManifest.xml | 2 +- example/pubspec.lock | 51 +++++++++++++------ pubspec.lock | 40 +++++++-------- 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index e691e8c..d30cce4 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> =2.12.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.17.0-0 <3.0.0" + flutter: ">=2.8.0" diff --git a/pubspec.lock b/pubspec.lock index 1d6f95d..5155ad1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,14 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -42,14 +42,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -78,21 +78,28 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" package_info: dependency: "direct main" description: @@ -106,7 +113,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" plugin_platform_interface: dependency: transitive description: @@ -125,7 +132,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -160,14 +167,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" url_launcher: dependency: "direct main" description: @@ -216,7 +216,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" From 42e94526e2532005832c10377227a1ef1a7b5846 Mon Sep 17 00:00:00 2001 From: Rounak Tadvi Date: Fri, 13 May 2022 21:23:51 +0530 Subject: [PATCH 2/4] chore(update-dependencies): update in_app_update,url_launcher to latest version, use package_info_plus instead of package_info plugin --- example/pubspec.lock | 64 +++++++++++++++++++++++-- lib/src/native_updater.dart | 42 ++++++++++------ pubspec.lock | 96 ++++++++++++++++++++++++++++++++++--- pubspec.yaml | 9 ++-- 4 files changed, 181 insertions(+), 30 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 8500fd0..22ef983 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -64,6 +64,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" flutter: dependency: "direct main" description: flutter @@ -79,6 +86,13 @@ packages: description: flutter source: sdk version: "0.0.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.4" http_parser: dependency: transitive description: @@ -92,7 +106,7 @@ packages: name: in_app_update url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" js: dependency: transitive description: @@ -128,13 +142,48 @@ packages: relative: true source: path version: "0.1.1" - package_info: + package_info_plus: + dependency: transitive + description: + name: package_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.2" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_macos: dependency: transitive description: - name: package_info + name: package_info_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "1.3.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" path: dependency: transitive description: @@ -266,6 +315,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.2" sdks: dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.8.0" diff --git a/lib/src/native_updater.dart b/lib/src/native_updater.dart index b7be4bd..8d6420e 100644 --- a/lib/src/native_updater.dart +++ b/lib/src/native_updater.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:in_app_update/in_app_update.dart'; -import 'package:package_info/package_info.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'error_material_alert.dart'; import 'update_cupertino_alert.dart'; @@ -59,11 +59,14 @@ class NativeUpdater { _nativeUpdaterInstance._iOSCloseButtonLabel = iOSCloseButtonLabel; _nativeUpdaterInstance._iOSIgnoreButtonLabel = iOSIgnoreButtonLabel; _nativeUpdaterInstance._iOSAlertTitle = iOSAlertTitle; - _nativeUpdaterInstance._requireUpdateText = requireUpdateText ?? 'requires that you update to the latest version. You cannot use this app until it is updated.'; - _nativeUpdaterInstance._recommendUpdateText = recommendUpdateText ?? 'recommends that you update to the latest version. You can keep using this app while downloading the update.'; + _nativeUpdaterInstance._requireUpdateText = requireUpdateText ?? + 'requires that you update to the latest version. You cannot use this app until it is updated.'; + _nativeUpdaterInstance._recommendUpdateText = recommendUpdateText ?? + 'recommends that you update to the latest version. You can keep using this app while downloading the update.'; _nativeUpdaterInstance._errorText = errorText; _nativeUpdaterInstance._errorCloseButtonLabel = errorCloseButtonLabel; _nativeUpdaterInstance._errorSubtitle = errorSubtitle; + /// Show the alert based on current platform if (Platform.isIOS) { _nativeUpdaterInstance._showCupertinoAlertDialog(); @@ -77,11 +80,9 @@ class NativeUpdater { String selectedDefaultDescription; if (_forceUpdate) { - selectedDefaultDescription = - '$_appName $_requireUpdateText'; + selectedDefaultDescription = '$_appName $_requireUpdateText'; } else { - selectedDefaultDescription = - '$_appName $_recommendUpdateText'; + selectedDefaultDescription = '$_appName $_recommendUpdateText'; } Widget alert = UpdateCupertinoAlert( @@ -109,13 +110,24 @@ class NativeUpdater { try { AppUpdateInfo _updateInfo = await InAppUpdate.checkForUpdate(); - if (_updateInfo.updateAvailability == UpdateAvailability.updateAvailable) { + if (_updateInfo.updateAvailability == + UpdateAvailability.updateAvailable) { if (_forceUpdate == true) { - InAppUpdate.performImmediateUpdate() - .catchError((e) => developer.log(e.toString())); + InAppUpdate.performImmediateUpdate().catchError( + (Object e) { + developer.log( + e.toString(), + ); + }, + ); } else if (_forceUpdate == false) { - InAppUpdate.startFlexibleUpdate() - .catchError((e) => developer.log(e.toString())); + InAppUpdate.startFlexibleUpdate().catchError( + (Object e) { + developer.log( + e.toString(), + ); + }, + ); } } } on PlatformException catch (e) { @@ -126,9 +138,9 @@ class NativeUpdater { builder: (BuildContext context) { return ErrorMaterialAlert( appName: _appName, - description: - _errorText ?? 'This version of $_appName was not installed from Google Play Store.', - errorCloseButtonLabel:_errorCloseButtonLabel, + description: _errorText ?? + 'This version of $_appName was not installed from Google Play Store.', + errorCloseButtonLabel: _errorCloseButtonLabel, errorSubtitle: _errorSubtitle, ); }, diff --git a/pubspec.lock b/pubspec.lock index 5155ad1..17f7e2a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" flutter: dependency: "direct main" description: flutter @@ -65,13 +72,27 @@ packages: description: flutter source: sdk version: "0.0.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.4" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" in_app_update: dependency: "direct main" description: name: in_app_update url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" js: dependency: transitive description: @@ -100,13 +121,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" - package_info: + package_info_plus: dependency: "direct main" description: - name: package_info + name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "1.4.2" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_macos: + dependency: transitive + description: + name: package_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" path: dependency: transitive description: @@ -168,13 +224,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" url_launcher: dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.10" + version: "6.1.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.16" url_launcher_linux: dependency: transitive description: @@ -217,6 +294,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.2" sdks: dart: ">=2.17.0-0 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index d7e0853..b06f677 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,7 @@ name: native_updater description: Flutter package for prompting users to update with a native dialog whether using the app store version or any version at the user's discretion. -author: Ofload -version: 0.1.1 +version: 0.1.2 homepage: https://github.com/ofload/native_updater environment: @@ -12,11 +11,11 @@ dependencies: flutter: sdk: flutter # package_info will help us to find current installed version of application. - package_info: ^2.0.2 + package_info_plus: ^1.4.2 # url_launcher will help us to trigger app store / play store url from our app. - url_launcher: ^6.0.10 + url_launcher: ^6.1.2 # Enables In App Updates on Android using the official Android APIs. - in_app_update: ^2.0.0 + in_app_update: ^3.0.0 dev_dependencies: flutter_test: From 075adcc2a641f472d93572923a063574f2b0bdfd Mon Sep 17 00:00:00 2001 From: Rounak Tadvi Date: Fri, 13 May 2022 21:26:53 +0530 Subject: [PATCH 3/4] refactor(codebase): refactor update_cupertino_alert,update_material_alert to use launchUrl method instead of launch method since launch method is deprecated --- lib/src/update_cupertino_alert.dart | 3 +-- lib/src/update_material_alert.dart | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/src/update_cupertino_alert.dart b/lib/src/update_cupertino_alert.dart index 25f5b49..1871d98 100644 --- a/lib/src/update_cupertino_alert.dart +++ b/lib/src/update_cupertino_alert.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class UpdateCupertinoAlert extends StatelessWidget { @@ -40,7 +39,7 @@ class UpdateCupertinoAlert extends StatelessWidget { Widget updateButton = CupertinoDialogAction( child: Text(updateButtonLabel), - onPressed: () => launch(appStoreUrl), + onPressed: () => launchUrl(Uri.parse(appStoreUrl)), ); return CupertinoAlertDialog( diff --git a/lib/src/update_material_alert.dart b/lib/src/update_material_alert.dart index 6182dbf..6ef5192 100644 --- a/lib/src/update_material_alert.dart +++ b/lib/src/update_material_alert.dart @@ -14,17 +14,16 @@ class UpdateMaterialAlert extends StatelessWidget { final String ignoreButtonLabel; final String newVersionLabel; - UpdateMaterialAlert({ - required this.forceUpdate, - required this.appName, - required this.playStoreUrl, - required this.titlePrefix, - required this.description, - required this.updateButtonLabel, - required this.closeButtonLabel, - required this.ignoreButtonLabel, - this.newVersionLabel = 'New version available' - }); + UpdateMaterialAlert( + {required this.forceUpdate, + required this.appName, + required this.playStoreUrl, + required this.titlePrefix, + required this.description, + required this.updateButtonLabel, + required this.closeButtonLabel, + required this.ignoreButtonLabel, + this.newVersionLabel = 'New version available'}); @override Widget build(BuildContext context) { @@ -47,7 +46,7 @@ class UpdateMaterialAlert extends StatelessWidget { child: Text(updateButtonLabel.toUpperCase(), style: TextStyle(color: Colors.white)), style: flatButtonStyle, - onPressed: () => launch(playStoreUrl), + onPressed: () => launchUrl(Uri.parse(playStoreUrl)), ); return AlertDialog( From 325da4851f996f40c61b20286890b7d5c74fb249 Mon Sep 17 00:00:00 2001 From: Rounak Tadvi Date: Fri, 13 May 2022 21:27:30 +0530 Subject: [PATCH 4/4] chore(dart-sdk-version): bump dart sdk version from 2.12.0 to 2.17.0 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b06f677..744526d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.1.2 homepage: https://github.com/ofload/native_updater environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: flutter: