🚀 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.


Libraries

auto_in_app_update