update_service 2.0.0 copy "update_service: ^2.0.0" to clipboard
update_service: ^2.0.0 copied to clipboard

Utility service that check whether an update is available in PlayStore or AppStore

update_service #

build pub package License: MIT

Utility service that checks whether an update is available according to semantic versioning.

Getting started #

Add a dependency to pubspec.yaml:

dependencies:
  update_service:
    git:
      url: https://github.com/XperiTech/flutter_tools
      path: update_service

Usage #

import 'package:flutter/foundation.dart';
import 'package:update_service/update_service.dart';

void main() async {
  final updateService = UpdateService.createDefault();

  final updateStatus = await updateService.checkStatus(skipUpdate: kDebugMode);

  updateStatus.when(
    required: (local, published) =>
        // major version changed
        // e.g. 1.0.0 -> 2.0.0
        updateService.openStore(),
    optional: (local, published) =>
        // minor or patch version changed
        // e.g. 1.0.0 -> 1.0.1
        //   or 1.0.0 -> 1.1.0
        print('update optional'),
    upToDate: ()
        // the app is up to date, don't do anything
        {},
    unknown: ()
        // can't determine if an update is available
        // some examples of this are when there's no internet connection
        // or when no app with the same package name was found
        {},
  );
}

Migration to 2.0.0 #

Usage #

import 'package:flutter/foundation.dart';
import 'package:update_service/update_service.dart';

void main() async {
  final updateService = UpdateService.createDefault();


  final updateStatus = await updateService.checkStatus(
    skipUpdate: kDebugMode,
    // [Optional] Specify the minimum required version for a force update
    forceUpdateVersion: '2.1.0',
  );

  updateStatus.when(
    required: (local, published) =>
        // Required update for versions lower than 2.1.0
        updateService.openStore(),
    optional: (local, published) =>
        // Update is optional if no forced version requirement is met
        // e.g. 1.0.0 -> 1.0.1
        //   or 1.0.0 -> 1.1.0
        print('update optional'),
    upToDate: ()
        // The app is up to date with the latest or meets the required version
        {},
    unknown: ()
        // Can't determine if an update is available due to network or other issues
        {},
  );
}
3
likes
120
points
60
downloads

Publisher

verified publisherxperitech.com

Weekly Downloads

Utility service that check whether an update is available in PlayStore or AppStore

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, freezed_annotation, html, http, package_info_plus, url_launcher

More

Packages that depend on update_service