in_app_update_android 1.0.5
in_app_update_android: ^1.0.5 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
- Quick Start
- Package Layout
- Usage
- API Reference
- Models
- Requirements
- Compatibility
- Changelog
- License
Installation #
Add this to your pubspec.yaml:
dependencies:
in_app_update_android: ^1.0.3
Then run:
flutter pub get
Quick Start #
import 'package:in_app_update_android/in_app_update_android.dart';
final inAppUpdate = InAppUpdateAndroid();
Package Layout #
lib/
├── in_app_update_android.dart # Public API – main entry point
└── src/
├── method_channel/
│ └── in_app_update_android_method_channel.dart # Method/event channel bridge
├── models/
│ ├── app_update_info_android.dart # Update metadata model
│ ├── install_state_android.dart # Install progress model
│ ├── install_status_android.dart # Install status enum
│ ├── models.dart # Barrel export
│ ├── update_availability_android.dart # Availability enum
│ └── update_result_android.dart # Result enum
└── platform_interface/
└── in_app_update_android_platform_interface.dart # Abstract platform API
android/src/main/kotlin/sajedur0/in_app_update_android/
└── InAppUpdateAndroidPlugin.kt # Native Android (Kotlin) implementation
The plugin follows Flutter's Platform Interface pattern:
InAppUpdateAndroidPlatform– abstract interface defining all methodsMethodChannelInAppUpdateAndroid– default implementation usingMethodChannel/EventChannelInAppUpdateAndroidPlugin(Kotlin) – Android-side handler via Play Core API
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 #
With built-in confirmation prompt (recommended)
import 'package:flutter/material.dart';
// Show a Material dialog with update details
final result = await inAppUpdate.showImmediateUpdatePrompt(
context,
title: 'Update Available',
updateButtonText: 'Update Now',
);
if (result == UpdateResultAndroid.success) {
// App is updating
}
Direct trigger (no prompt)
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. |
| showImmediateUpdatePrompt(BuildContext context, {bool allowAssetPackDeletion, String title, String? message, String updateButtonText, String cancelButtonText}) | Future<UpdateResultAndroid?> | Shows a Material confirmation dialog before starting the immediate update. Returns null if dismissed or no update is available. |
| 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