Skip to content

Commit

Permalink
Add new option disableOptionalUpdates
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedLSayed9 committed Oct 30, 2024
1 parent 54e4869 commit a898cba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ The `Upgrader` class can be customized by setting parameters in the constructor,
* languageCode: the language code that will override the system locale, which defaults to ```null```
* messages: optional localized messages used for display in `upgrader`
* minAppVersion: the minimum app version supported by this app. Earlier versions of this app will be forced to update to the current version. It should be a valid version string like this: ```2.0.13```. Overrides any minimum app version from UpgraderStore. Defaults to ```null```.
* disableOptionalUpdates: If set to `true`, this flag will disable optional app updates for the current version.
When disabled, only mandatory updates (those below minimum app version) will be prompted to the user. Defaults to `false`.
* storeController: a controller that provides the store details for each platform, defaults to `UpgraderStoreController()`.
* upgraderDevice: an abstraction of the device_info details which is used for the OS version, defaults to `UpgraderDevice()`.
* upgraderOS: information on which OS this code is running on, defaults to `UpgraderOS()`.
Expand Down
6 changes: 6 additions & 0 deletions lib/src/upgrade_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class UpgraderState {
this.languageCodeOverride,
this.messages,
this.minAppVersion,
this.disableOptionalUpdates = false,
this.packageInfo,
required this.upgraderDevice,
required this.upgraderOS,
Expand Down Expand Up @@ -62,6 +63,11 @@ class UpgraderState {
/// app version from UpgraderStore. Optional.
final Version? minAppVersion;

/// If set to `true`, this flag will disable optional app updates for the current version.
/// When disabled, only mandatory updates (those below minimum app version) will be
/// prompted to the user. Defaults to `false`.
final bool disableOptionalUpdates;

/// The app package metadata information.
final PackageInfo? packageInfo;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/upgrader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class Upgrader with WidgetsBindingObserver {
bool rv = true;
if (state.debugDisplayAlways || (state.debugDisplayOnce && !_hasAlerted)) {
rv = true;
} else if (!isUpdateAvailable()) {
} else if (!isUpdateAvailable() || state.disableOptionalUpdates) {
rv = false;
} else if (isBlocked) {
rv = true;
Expand Down

0 comments on commit a898cba

Please sign in to comment.