Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="Your App"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
115 changes: 96 additions & 19 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.7.0"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
Expand All @@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -63,7 +63,14 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
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
Expand All @@ -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:
Expand All @@ -92,49 +106,91 @@ packages:
name: in_app_update
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "3.0.0"
js:
dependency: transitive
description:
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.4.0"
version: "1.7.0"
native_updater:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.1.0"
package_info:
version: "0.1.1"
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
name: package_info_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
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:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -153,7 +209,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:
Expand Down Expand Up @@ -188,7 +244,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
version: "0.4.9"
typed_data:
dependency: transitive
description:
Expand All @@ -202,7 +258,21 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.6"
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:
Expand Down Expand Up @@ -244,7 +314,14 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.2"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.2"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.8.0"
42 changes: 27 additions & 15 deletions lib/src/native_updater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -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(
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
);
},
Expand Down
3 changes: 1 addition & 2 deletions lib/src/update_cupertino_alert.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -40,7 +39,7 @@ class UpdateCupertinoAlert extends StatelessWidget {

Widget updateButton = CupertinoDialogAction(
child: Text(updateButtonLabel),
onPressed: () => launch(appStoreUrl),
onPressed: () => launchUrl(Uri.parse(appStoreUrl)),
);

return CupertinoAlertDialog(
Expand Down
23 changes: 11 additions & 12 deletions lib/src/update_material_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(
Expand Down
Loading