in_app_update_android 1.0.2
in_app_update_android: ^1.0.2 copied to clipboard
A Flutter plugin for prompting users about Android in-app updates using Play Core API.
in_app_update_android
A Flutter plugin for Android in-app updates using Google Play's In-App Updates API.
Supports immediate (blocking) and flexible (background) update flows with real-time download progress tracking.
Features #
- Update Availability Check – Query Google Play to see if an update is available for your app.
- Immediate Updates – Full-screen, blocking update flow that users must accept to continue.
- Flexible Updates – Background download with progress tracking; install when ready.
- Download Progress Stream – Real-time
InstallStateAndroidevents via a Dart stream. - Install Status Tracking – Monitor pending, downloading, downloaded, installing, installed, failed, and canceled states.
Table of Contents #
Installation #
Add this to your pubspec.yaml:
dependencies:
in_app_update_android: ^1.0.1
Then run:
flutter pub get
Quick Start #
import 'package:in_app_update_android/in_app_update_android.dart';
final inAppUpdate = InAppUpdateAndroid();
Usage #
Check for Updates #
final info = await inAppUpdate.checkUpdateAndroid();
if (info.updateAvailability == UpdateAvailabilityAndroid.updateAvailable) {
print('Version code: ${info.availableVersionCode}');
print('Update priority: ${info.updatePriority}');
print('Staleness days: ${info.clientVersionStalenessDays}');
}
Immediate Update #
final result = await inAppUpdate.startImmediateUpdateAndroid();
switch (result) {
case UpdateResultAndroid.success:
// App is updating
break;
case UpdateResultAndroid.userCanceled:
// User dismissed the update
break;
case UpdateResultAndroid.inAppUpdateFailed:
// An error occurred
break;
}
Flexible Update #
// 1. Listen for download progress
final subscription = inAppUpdate.installStateStreamAndroid.listen((state) {
final progress = state.bytesDownloaded / state.totalBytesToDownload * 100;
print('Download progress: ${progress.toStringAsFixed(1)}%');
});
// 2. Start the flexible update
final result = await inAppUpdate.startFlexibleUpdateAndroid();
if (result == UpdateResultAndroid.success) {
// 3. Complete the installation (triggers app restart)
await inAppUpdate.completeUpdateAndroid();
}
API Reference #
InAppUpdateAndroid #
| Method / Property | Returns | Description |
|---|---|---|
checkUpdateAndroid() |
Future<AppUpdateInfoAndroid> |
Checks for an available update via Play Core. |
startImmediateUpdateAndroid({bool allowAssetPackDeletion}) |
Future<UpdateResultAndroid> |
Starts a full-screen blocking update flow. |
startFlexibleUpdateAndroid({bool allowAssetPackDeletion}) |
Future<UpdateResultAndroid> |
Starts a background download update flow. |
completeUpdateAndroid() |
Future<void> |
Installs a downloaded flexible update (triggers app restart). |
installStateStreamAndroid |
Stream<InstallStateAndroid> |
Stream of download progress and status events. |
Models #
AppUpdateInfoAndroid #
| Field | Type | Description |
|---|---|---|
updateAvailability |
UpdateAvailabilityAndroid |
Whether an update is available. |
availableVersionCode |
int? |
Version code of the available update. |
updatePriority |
int |
Priority (0–5) set via Play Developer API. |
clientVersionStalenessDays |
int? |
Days since the update became available. |
isImmediateUpdateAllowed |
bool |
Whether immediate update is permitted. |
isFlexibleUpdateAllowed |
bool |
Whether flexible update is permitted. |
installStatus |
InstallStatusAndroid |
Current install status. |
InstallStateAndroid #
| Field | Type | Description |
|---|---|---|
status |
InstallStatusAndroid |
Current install state. |
bytesDownloaded |
int |
Bytes downloaded so far. |
totalBytesToDownload |
int |
Total bytes to download. |
Enums #
| Enum | Values |
|---|---|
UpdateAvailabilityAndroid |
unknown, updateNotAvailable, updateAvailable, developerTriggeredUpdateInProgress |
InstallStatusAndroid |
unknown, pending, downloading, downloaded, installing, installed, failed, canceled |
UpdateResultAndroid |
success, userCanceled, inAppUpdateFailed |
Requirements #
| Requirement | Minimum |
|---|---|
| Android SDK | minSdk = 21 (Android 5.0) |
| Dart SDK | ^3.12.2 |
| Flutter SDK | >=3.3.0 |
Compatibility #
| Version | Dart SDK | Flutter SDK | Android |
|---|---|---|---|
1.0.x |
^3.12.2 |
>=3.3.0 |
minSdk 21 |
The badges at the top of this README automatically reflect the latest version published on pub.dev.
Changelog #
See CHANGELOG.md for version history.
License #
This project is licensed under the MIT License – see the LICENSE file for details.
Developed by Sajedur0
Report a bug ·
Request a feature