smart_update_manager 0.1.0 copy "smart_update_manager: ^0.1.0" to clipboard
smart_update_manager: ^0.1.0 copied to clipboard

A plug-and-play solution to detect app updates and enforce soft or force updates on Android, iOS, macOS, Windows, and Linux.

Smart Update Manager 📦 #

A plug-and-play solution to detect app updates and enforce soft or force updates on Android, iOS, macOS, Windows, and Linux.

pub package ![License: MIT](https://img.shields.io/badge/License: MIT-yellow.svg)

Features #

  • Semantic Versioning: Robust numerical comparison (ignoring build numbers).
  • Update States: Distinct logic for Force, Soft, and No Update.
  • Platform-Specific Versions: Set different version thresholds for Android, iOS, macOS, Windows, and Linux (with global fallback).
  • Plug-and-Play UI: Default Material and Cupertino dialogs built-in.
  • Store Redirection: Automatic handling for Google Play Store, Apple App Store, Mac App Store, and Microsoft Store.
  • Customizable: Override titles, messages, and dialog styling.
  • Production Ready: Lightweight with minimal dependencies.
  • Cross-Platform Support: Android, iOS, macOS, Windows, Linux, and Web (Web skips updates).

Installation #

Add the following to your pubspec.yaml:

dependencies:
  smart_update_manager: ^0.1.0

Important: After adding this package, stop your application completely and run it again using flutter run. A Hot Reload or Hot Restart is not sufficient because the package depends on native plugins.

Basic Usage #

1. Initialize Configuration #

Create an UpdateConfig with your version thresholds and store identifiers. Usually, you'll fetch these from your backend or Firebase Remote Config.

Option 1: Global versions for all platforms

final config = UpdateConfig(
  minimumRequiredVersion: AppVersion.parse('1.1.0'), // Force update below this
  latestAvailableVersion: AppVersion.parse('1.2.0'), // Soft update below this
  androidId: 'com.your.package',
  iosId: '123456789',
);

Option 2: Platform-specific versions (with global fallback)

final config = UpdateConfig(
  // Global versions (used if no platform-specific version is set)
  minimumRequiredVersion: AppVersion.parse('1.0.0'), // Fallback for all platforms
  latestAvailableVersion: AppVersion.parse('1.0.6'), // Fallback for all platforms
  // Android versions (overrides global)
  minimumRequiredAndroidVersion: AppVersion.parse('1.2.0'),
  latestAndroidVersion: AppVersion.parse('1.3.0'),
  androidId: 'com.your.package',
  // iOS versions (not set, so uses global versions)
  iosId: '123456789',
);

How it works: Platform-specific versions take precedence. If a platform doesn't have specific versions set, it falls back to the global versions. This is perfect for when you want most platforms to use the same versions but need different thresholds for one or two specific platforms.

2. Check and Show Update Dialog #

Call checkAndShowUpdate on app launch or whenever needed. The manager automatically detects the platform and shows the appropriate dialog.

await SmartUpdateManager.checkAndShowUpdate(
  context,
  config: config,
);

Advanced Customization #

You can customize the text and basic styling of the built-in dialogs:

await SmartUpdateManager.checkAndShowUpdate(
  context,
  config: config,
  softUpdateTitle: 'New Version Found',
  updateButtonText: 'Update Now!',
  titleTextStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.deepPurple),
  updateButtonStyle: ElevatedButton.styleFrom(backgroundColor: Colors.deepPurple),
  barrierDismissible: true,
);

Full UI Customization #

For complete control over the UI, use the dialogBuilder. This allows you to show a bottom sheet, a full-screen page, or a completely custom dialog.

await SmartUpdateManager.checkAndShowUpdate(
  context,
  config: config,
  dialogBuilder: (context, state, onUpdate, onLater) {
    return MyCustomUpdateWidget(
      isForce: state == UpdateState.force,
      onUpdate: onUpdate,
      onLater: onLater,
    );
  },
);

Manual Control #

If you prefer to build your own UI, you can just use the logic directly:

final state = await SmartUpdateManager.checkUpdate(config);

if (state == UpdateState.force) {
  // Show your own custom full-screen blocking UI
}

Supported Platforms #

Platform Supported Redirection
Android Google Play Store
iOS Apple App Store
macOS Mac App Store
Windows Microsoft Store
Linux Custom Update URL
Web (skips update checks)

License #

MIT

2
likes
160
points
12
downloads

Documentation

API reference

Publisher

verified publishergreelogix.com

Weekly Downloads

A plug-and-play solution to detect app updates and enforce soft or force updates on Android, iOS, macOS, Windows, and Linux.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, package_info_plus, pub_semver, url_launcher

More

Packages that depend on smart_update_manager