app_update_helper 1.0.9 copy "app_update_helper: ^1.0.9" to clipboard
app_update_helper: ^1.0.9 copied to clipboard

Simply check for updates, then based on the version (major, minor, patch) decide to update or not.

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool userCanUpdate = false;

  void allowUpdateIfMajorOrMinorVersion() async {
    final update = await AppUpdateHelper.checkForUpdate();

    switch (update.type) {
      case UpdateType.major:
      case UpdateType.minor:
        setState(() => userCanUpdate = true);
        break;
      default:
    }
  }

  @override
  void initState() {
    super.initState();
    allowUpdateIfMajorOrMinorVersion();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: userCanUpdate
              ? ElevatedButton(
                  onPressed: () => AppUpdateHelper.update(),
                  child: const Text('Update App'),
                )
              : const Text("no update available"),
        ),
      ),
    );
  }
}
1
likes
160
points
297
downloads

Publisher

verified publisherzealousfoundry.com

Weekly Downloads

Simply check for updates, then based on the version (major, minor, patch) decide to update or not.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, package_info_plus, plugin_platform_interface, url_launcher

More

Packages that depend on app_update_helper

Packages that implement app_update_helper