on_upgrade 1.0.0
on_upgrade: ^1.0.0 copied to clipboard

Local upgrade checker plugin. Provides the ability to compare the currently running app version against a saved one.

Pub Version codecov GitHub Workflow Status GitHub likes popularity pub points

OnUpgrade #

Local upgrade checker plugin for Flutter. Enables the developer to easily migrate data between upgrades or to show users a new features dialog.

Features #

A simple upgrade checker to migrate data between app updates or to display a change log with new features to your users.

  • Contains a default implementation using the shared preferences of the platform to persist the last known version
  • Minimal effort to check if an app update is given and to updated the persisted values
  • Possibility to implement custom getters and setters for the persisted version interaction (e.g. if the last known app version is already available via a database)

Usage #

Getting Started #

Add this to your package's pubspec.yaml file:

dependencies:
  on_upgrade: ^1.0.0

More information on pub.dev.

Examples #

For full examples please see the example app.

Default Implementation #

final onUpgrade = OnUpgrade();
final isNewVersion = await onUpgrade.isNewVersion();
if (isNewVersion.state == UpgradeState.upgrade) {
  await onUpgrade.updateLastVersion();
  myDataMigration(isNewVersion.currentVersion);
  myShowUserNewFeaturesDialog(isNewVersion.currentVersion);
}

Custom Implementation #

Future<String> _customVersionGetter() async {
    // Your implementation. Load the last known version.
    // Must return an empty string if no initial version is known (first app start, before calling updateLastVersion().
}

Future<bool> _customVersionSetter([String version]) async {
    // Your implementation. Update the last known version, after performing the upgrade check and starting all migration / information actions.
}

final onUpgradeCustom = OnUpgrade(customVersionUpdate: _customVersionSetter, customVersionLookup: _customVersionGetter);
final isNewVersion = await onUpgradeCustom.isNewVersion();
if (isNewVersion.state == UpgradeState.upgrade) {
  await onUpgradeCustom.updateLastVersion();
  myDataMigration(isNewVersion.currentVersion);
  myShowUserNewFeaturesDialog(isNewVersion.currentVersion);
}
4
likes
130
pub points
38%
popularity

Publisher

boehrsi.de

Local upgrade checker plugin. Provides the ability to compare the currently running app version against a saved one.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter, package_info_plus, shared_preferences

More

Packages that depend on on_upgrade