OnUpgrade class
Contains the upgrade check functionality
The last know version must be set via updateLastVersion.
Usage with default implementation:
final onUpgrade = OnUpgrade();
final isNewVersion = await onUpgrade.isNewVersion();
if (isNewVersion.state == UpgradeState.upgrade) {
myDataMigrationOrNewFeatureDialog(isNewVersion.currentVersion!);
await onUpgrade.updateLastVersion();
}
Constructors
- OnUpgrade({String keyLastVersion = 'on_upgrade.version', VersionLookup? customVersionLookup, VersionUpdate? customVersionUpdate})
Properties
- customVersionLookup → VersionLookup?
-
Optional last version getter. If set keyLastVersion isn't used and customVersionUpdate is required to be also set.
final
- customVersionUpdate → VersionUpdate?
-
Optional last version setter. If set keyLastVersion isn't used and customVersionLookup is required to be also set
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyLastVersion → String
-
Configures a custom key used in the shared preferences. Defaults to
on_upgrade.version
final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getCurrentVersion(
) → Future< String> - Returns the currently running version
-
getLastVersion(
) → Future< String> - Returns the last known version or '0.0.0' as initial fallback value. Call updateLastVersion to update this value
-
isInitialInstallation(
) → Future< bool> - Returns if the current app start is the first start overall.
-
isNewVersion(
) → Future< UpgradeWrapper> - Returns the upgrade state.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateLastVersion(
[String? version]) → Future< bool> - Sets the last know version and persists it. If called without parameter the currently running version is set.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited