update_helper 0.7.1 copy "update_helper: ^0.7.1" to clipboard
update_helper: ^0.7.1 copied to clipboard

Help you easier to control the update dialog. It also supports the feature that forces the app to update to continue using.

example/lib/main.dart

// ignore_for_file: invalid_use_of_visible_for_testing_member, avoid_print

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

void main() {
  runApp(const MaterialApp(home: MyApp()));
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  final updateHelper = UpdateHelper.instance;

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

    WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
      // Adding testing package name, don't need this in real app
      updateHelper.packageName = 'com.vursin.othello';

      print('Show normal update dialog. Just press Later');
      await UpdateHelper.instance.initial(
        context: context,
        updateConfig: UpdateConfig(
          defaultConfig: UpdatePlatformConfig(latestVersion: '0.0.6'),
        ),
        changelogs: ['Improve performances', 'Update UI'],
        isDebug: true,
      );

      print('Don\'t show dialog because [onlyShowDialogWhenForce] is `true`'
          'but [forceUpdate] is `false`');
      if (mounted) {
        await UpdateHelper.instance.initial(
          context: context,
          updateConfig: UpdateConfig(
            defaultConfig: UpdatePlatformConfig(latestVersion: '0.0.6'),
          ),
          onlyShowDialogWhenBanned: true,
          changelogs: ['Improve performances', 'Update UI'],
          isDebug: true,
        );
      }

      print('Show dialog because [onlyShowDialogWhenForce] is `true`'
          'and [forceUpdate] is `true`');
      if (mounted) {
        await UpdateHelper.instance.initial(
          context: context,
          updateConfig: UpdateConfig(
            defaultConfig: UpdatePlatformConfig(latestVersion: '0.0.6'),
          ),
          onlyShowDialogWhenBanned: true,
          forceUpdate: true,
          isDebug: true,
        );
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: const Center(
        child: Text(''),
      ),
    );
  }
}
5
likes
130
pub points
60%
popularity

Publisher

verified publisherlamnhan.dev

Help you easier to control the update dialog. It also supports the feature that forces the app to update to continue using.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

boxw, flutter, http, package_info_plus, satisfied_version, universal_platform, url_launcher

More

Packages that depend on update_helper