Allow to disable error modal with showErrorDialog

This commit is contained in:
Sambo Chea 2022-10-28 11:04:02 +07:00
parent 6b813a0285
commit 044645c01a

View File

@ -12,6 +12,7 @@ import 'update_cupertino_alert.dart';
class NativeUpdater { class NativeUpdater {
late BuildContext _context; late BuildContext _context;
late bool _forceUpdate; late bool _forceUpdate;
late bool _showErrorDialog;
late String _appName; late String _appName;
String? _appStoreUrl; String? _appStoreUrl;
String? _iOSDescription; String? _iOSDescription;
@ -34,6 +35,7 @@ class NativeUpdater {
static displayUpdateAlert( static displayUpdateAlert(
BuildContext context, { BuildContext context, {
required bool forceUpdate, required bool forceUpdate,
bool? showErrorDialog,
String? appStoreUrl, String? appStoreUrl,
String? iOSDescription, String? iOSDescription,
String? iOSUpdateButtonLabel, String? iOSUpdateButtonLabel,
@ -52,6 +54,7 @@ class NativeUpdater {
/// Set singleton properties /// Set singleton properties
_nativeUpdaterInstance._context = context; _nativeUpdaterInstance._context = context;
_nativeUpdaterInstance._forceUpdate = forceUpdate; _nativeUpdaterInstance._forceUpdate = forceUpdate;
_nativeUpdaterInstance._showErrorDialog = showErrorDialog;
_nativeUpdaterInstance._appName = info.appName; _nativeUpdaterInstance._appName = info.appName;
_nativeUpdaterInstance._appStoreUrl = appStoreUrl; _nativeUpdaterInstance._appStoreUrl = appStoreUrl;
_nativeUpdaterInstance._iOSDescription = iOSDescription; _nativeUpdaterInstance._iOSDescription = iOSDescription;
@ -119,6 +122,10 @@ class NativeUpdater {
} }
} }
} on PlatformException catch (e) { } on PlatformException catch (e) {
if (_showErrorDialog == true) {
return;
}
developer.log(e.code.toString()); developer.log(e.code.toString());
showDialog( showDialog(