flutter_app_auto_update_checker 1.0.0 copy "flutter_app_auto_update_checker: ^1.0.0" to clipboard
flutter_app_auto_update_checker: ^1.0.0 copied to clipboard

A lightweight, cross-platform Flutter package that automatically checks for app updates from Google Play Store and Apple App Store, compares versions, and shows customizable update dialogs.

πŸš€ Flutter App Auto Update Checker #

pub package License: MIT

A lightweight, cross-platform Flutter package that automatically checks for app updates from Google Play Store (Android) and Apple App Store (iOS), compares versions, and shows customizable update dialogs.

✨ Features #

  • βœ… Cross-platform support - Works on both Android and iOS
  • βœ… Automatic version checking - Fetches latest version from app stores
  • βœ… Smart version comparison - Compares semantic versions accurately
  • βœ… Customizable dialog - Beautiful, customizable update dialog with release notes
  • βœ… Easy integration - Simple API with minimal code
  • βœ… Lightweight - No heavy dependencies
  • βœ… Production-ready - Built for real-world applications

πŸ“¦ Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_app_auto_update_checker: ^1.0.0

Then run:

flutter pub get

πŸš€ Quick Start #

1. Basic Usage #

import 'package:flutter_app_auto_update_checker/flutter_app_auto_update_checker.dart';

// Check for updates
final updateInfo = await UpdateCheckerService.checkForUpdate();

if (updateInfo.hasUpdate) {
  // Show update dialog
  UpdateDialog.show(context, updateInfo: updateInfo);
}

2. Complete Example #

import 'package:flutter/material.dart';
import 'package:flutter_app_auto_update_checker/flutter_app_auto_update_checker.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
    _checkForUpdate();
  }

  Future<void> _checkForUpdate() async {
    // Check for updates
    final updateInfo = await UpdateCheckerService.checkForUpdate();

    if (updateInfo.hasUpdate && mounted) {
      // Show update dialog
      UpdateDialog.show(
        context,
        updateInfo: updateInfo,
        title: 'Update Available!',
        message: 'A new version of the app is available.',
        updateButtonText: 'Update Now',
        laterButtonText: 'Later',
        isCritical: false, // Set to true for forced updates
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Auto Update Checker'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.check_circle_outline,
              size: 64,
              color: Colors.green,
            ),
            const SizedBox(height: 16),
            const Text(
              'Update Check Complete',
              style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 8),
            const Text('Your app is up to date!'),
            const SizedBox(height: 24),
            ElevatedButton.icon(
              onPressed: _checkForUpdate,
              icon: const Icon(Icons.refresh),
              label: const Text('Check Again'),
            ),
          ],
        ),
      ),
    );
  }
}

πŸ“– API Reference #

UpdateCheckerService #

Main service class for checking app updates.

Methods

checkForUpdate({String? packageName})

Checks for app updates from the respective app store.

Parameters:

  • packageName (optional): The app's package name (Android) or bundle ID (iOS). If not provided, it will be fetched automatically.

Returns: Future<AppUpdateInfo>

Example:

final updateInfo = await UpdateCheckerService.checkForUpdate();

AppUpdateInfo #

Model class containing app update information.

Properties:

  • currentVersion (String): The current version of the installed app
  • latestVersion (String): The latest version available on the store
  • hasUpdate (bool): Whether an update is available
  • packageName (String): The app's package name (Android) or bundle ID (iOS)
  • storeUrl (String): The URL to the app store listing
  • releaseNotes (String?): Release notes or changelog for the update
  • isCritical (bool): Whether this is a critical/forced update

Example:

if (updateInfo.hasUpdate) {
  print('Update available: ${updateInfo.currentVersion} -> ${updateInfo.latestVersion}');
}

UpdateDialog #

A customizable dialog widget for displaying app update information.

Constructor

UpdateDialog({
  required AppUpdateInfo updateInfo,
  String title = 'Update Available',
  String? message,
  String updateButtonText = 'Update Now',
  String laterButtonText = 'Later',
  bool showLaterButton = true,
  VoidCallback? onUpdatePressed,
  VoidCallback? onLaterPressed,
  bool isCritical = false,
})

Static Method: show()

Shows the update dialog.

Parameters:

  • context (BuildContext): The build context
  • updateInfo (AppUpdateInfo): The app update information to display
  • title (String): Title of the dialog (default: 'Update Available')
  • message (String?): Message to display in the dialog
  • updateButtonText (String): Text for the update button (default: 'Update Now')
  • laterButtonText (String): Text for the later button (default: 'Later')
  • showLaterButton (bool): Whether to show the later button (default: true)
  • onUpdatePressed (VoidCallback?): Callback when update button is pressed
  • onLaterPressed (VoidCallback?): Callback when later button is pressed
  • isCritical (bool): Whether this is a critical update (forces update) (default: false)

Example:

UpdateDialog.show(
  context,
  updateInfo: updateInfo,
  title: 'New Version Available!',
  message: 'Please update to the latest version.',
  updateButtonText: 'Update Now',
  laterButtonText: 'Maybe Later',
  isCritical: false,
);

🎨 Customization #

Custom Update Dialog #

You can customize the update dialog by providing your own callbacks:

UpdateDialog.show(
  context,
  updateInfo: updateInfo,
  title: 'Update Required',
  message: 'This update includes important security fixes.',
  updateButtonText: 'Update Now',
  laterButtonText: 'Remind Me Later',
  showLaterButton: false, // Hide later button for critical updates
  isCritical: true, // Force update (prevents dismissing dialog)
  onUpdatePressed: () {
    // Custom action when update is pressed
    print('Update pressed!');
  },
  onLaterPressed: () {
    // Custom action when later is pressed
    print('Later pressed!');
  },
);

Forced Updates #

To force users to update (prevent dismissing the dialog):

UpdateDialog.show(
  context,
  updateInfo: updateInfo,
  isCritical: true, // This prevents dismissing the dialog
);

πŸ”§ Advanced Usage #

Check Updates on App Launch #

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'My App',
      home: const HomePage(),
      builder: (context, child) {
        // Check for updates when app starts
        WidgetsBinding.instance.addPostFrameCallback((_) {
          _checkForUpdate(context);
        });
        return child!;
      },
    );
  }

  Future<void> _checkForUpdate(BuildContext context) async {
    final updateInfo = await UpdateCheckerService.checkForUpdate();
    
    if (updateInfo.hasUpdate && context.mounted) {
      UpdateDialog.show(context, updateInfo: updateInfo);
    }
  }
}

Check Updates Periodically #

class UpdateChecker {
  static Timer? _timer;

  static void startPeriodicCheck(BuildContext context) {
    _timer = Timer.periodic(const Duration(hours: 24), (timer) async {
      final updateInfo = await UpdateCheckerService.checkForUpdate();
      
      if (updateInfo.hasUpdate && context.mounted) {
        UpdateDialog.show(context, updateInfo: updateInfo);
      }
    });
  }

  static void stopPeriodicCheck() {
    _timer?.cancel();
    _timer = null;
  }
}

πŸ› Troubleshooting #

Issue: Update not detected #

Solution: Make sure your app is published on the app store. The package fetches version information from the official app store pages.

Issue: iOS version not detected #

Solution: The iTunes Search API might take some time to index your app after publishing. Wait a few hours and try again.

Issue: Android version not detected #

Solution: Ensure your app is published on Google Play Store and the package name matches exactly.

πŸ“ License #

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author #

Raza Khan

🀝 Contributing #

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

⭐ Support #

If you like this package, please consider giving it a ⭐ on pub.flutter-io.cn!

πŸ“„ Changelog #

See CHANGELOG.md for a list of changes.


Made with ❀️ by Raza Khan

0
likes
130
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight, cross-platform Flutter package that automatically checks for app updates from Google Play Store and Apple App Store, compares versions, and shows customizable update dialogs.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, package_info_plus, url_launcher

More

Packages that depend on flutter_app_auto_update_checker