app_update_monitor 1.0.1 copy "app_update_monitor: ^1.0.1" to clipboard
app_update_monitor: ^1.0.1 copied to clipboard

A lightweight Flutter package that effortlessly checks for app updates by comparing the installed version with the latest version available on the Apple App Store and Google Play Store.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const HomePage(),
    );
  }
}

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

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

class _HomePageState extends State<HomePage> {
  Future<void> checkForUpdates(BuildContext context) async {
    final versionChecker = VersionChecker(
      appleId: '1234567',
      googlePlayPackageName: 'com.example.app',
    );

    try {
      final versionInfo = await versionChecker.checkVersion();

      if (!context.mounted) return;

      if (versionInfo.shouldUpdate) {
        showDialog(
          context: context,
          builder: (_) => UpdateDialog(
            versionInfo: versionInfo,
            mandatoryUpdate: false,
            laterButtonText: 'Update later',
          ),
        );
      }
    } catch (e) {
      if (!context.mounted) return;
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Error checking version: $e')),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Version Checker Example')),
      body: Center(
        child: Builder(
          builder: (innerContext) => ElevatedButton(
            onPressed: () => checkForUpdates(innerContext),
            child: const Text('Check for Updates'),
          ),
        ),
      ),
    );
  }
}
1
likes
130
points
45
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Flutter package that effortlessly checks for app updates by comparing the installed version with the latest version available on the Apple App Store and Google Play Store.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, package_info_plus, url_launcher

More

Packages that depend on app_update_monitor