auto_in_app_update 0.0.4
auto_in_app_update: ^0.0.4 copied to clipboard
A lightweight Flutter package for automatic in-app update handling on Android (using in_app_update) with a placeholder for iOS.
π auto_in_app_update #
A lightweight Flutter package for automatically checking and initiating in-app updates on Android using the in_app_update plugin. On iOS, it logs a placeholder message (you can implement update logic using packages like upgrader).
β¨ Features #
- β Automatically checks for updates on app startup
- π Supports both flexible and immediate updates on Android
- πͺΆ No UI integration required β plug and play
- π§ Logs a message for iOS (custom update logic can be added)
- π§ Designed to be called only once (prevents multiple checks)
π¦ Installation #
1οΈβ£ Add Dependency #
In your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
auto_in_app_update: ^0.0.3
Then run:
flutter pub get
2οΈβ£ Android Setup #
Ensure your Android project is configured correctly:
β Set Minimum SDK Version
Open android/app/build.gradle and set:
defaultConfig {
minSdkVersion 21
}
β οΈ Note:
- Works only on real Android devices with Google Play Store.
- Does not work on emulators or non-GMS (Google Mobile Services) devices.
π Usage #
Step 1: Import and Initialize #
import 'package:flutter/material.dart';
import 'package:auto_in_app_update/auto_in_app_update.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// β
Automatically checks for available updates on app startup
await AutoInAppUpdate.checkForUpdate();
runApp(MyApp());
}
Step 2: Your App UI #
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Auto In-App Update Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Home')),
body: Center(child: Text('Welcome to the updated app!')),
);
}
}
π± Platform Behavior #
| Platform | Behavior |
|---|---|
| Android | Checks for updates on launch. Performs immediate update if allowed, else flexible update. |
| iOS | Logs: iOS update check: Use Upgrader widget in your app. You can add your own iOS update prompt using upgrader. |
π§ͺ Advanced Example (Optional Logging) #
await AutoInAppUpdate.checkForUpdate().then((_) {
print('Update check complete.');
}).catchError((e) {
print('Update check failed: $e');
});
βFAQ #
Q: Will this package show any update UI?
A: No β this package is headless. All update prompts come from Play Storeβs native UI based on update type (immediate/flexible).
Q: Can I use this for iOS?
A: Not directly. For iOS, consider integrating upgrader and managing the update flow manually with a BuildContext.