in_app_update 1.1.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

pub package

Presented by

https://ffuf.de

Maintained by Jonas Bark

in_app_update #

Enables In App Updates on Android using the official Android APIs.

https://developer.android.com/guide/app-bundle/in-app-updates

Documentation #

The following methods are exposed:

  • Future<AppUpdateInfo> checkForUpdate(): Checks if there's an update available
  • Future<void> performImmediateUpdate(): Performs an immediate update (full-screen)
  • Future<void> startFlexibleUpdate(): Starts a flexible update (background download)
  • Future<void> completeFlexibleUpdate(): Actually installs an available flexible update

Please have a look in the example app on how to use it!

Android #

This plugin integrates the official Android APIs to perform in app updated that were released in 2019: https://developer.android.com/guide/app-bundle/in-app-updates

iOS #

iOS does not offer such a functionality. You might want to look into e.g. https://pub.dev/packages/upgrader. If you call the methods above on a iOS device you'll run into a not-implemented exception.

1.1.7 #

  • Fix Crashes (#12, #15, #19)

1.1.6 #

  • Handle cases where no foreground activity is available (#10)

1.1.5 #

  • Fix Result already submitted exception (#8)

1.1.4 #

1.1.3 #

  • Fix Android build.

1.1.1 #

  • Breaking change: Renamed InAppUpdateState to AppUpdateInfo to mirror the Android SDK and the updateType property has been replaced by immediateUpdateAllowed & flexibleUpdateAllowed. The updateType property was previously broken. Consequently, refactoring is sensible. This also means that UpdateType has been removed.
  • Added support for resuming immediate updates that were cancelled. This is handled automatically and does not require any Flutter-side code.
  • Added documentation to the library.

1.0.2 #

  • Readme and example updates

1.0.0 #

  • First version released.

example/lib/main.dart

import 'dart:async';

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  AppUpdateInfo _updateInfo;

  GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey();

  bool _flexibleUpdateAvailable = false;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> checkForUpdate() async {
    InAppUpdate.checkForUpdate().then((info) {
      setState(() {
        _updateInfo = info;
      });
    }).catchError((e) => _showError(e));
  }

  void _showError(dynamic exception) {
    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(exception.toString())));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: const Text('In App Update Example App'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: <Widget>[
              Center(
                child: Text('Update info: $_updateInfo'),
              ),
              RaisedButton(
                child: Text('Check for Update'),
                onPressed: () => checkForUpdate(),
              ),
              RaisedButton(
                child: Text('Perform immediate update'),
                onPressed: _updateInfo?.updateAvailable == true
                    ? () {
                        InAppUpdate.performImmediateUpdate().catchError((e) => _showError(e));
                      }
                    : null,
              ),
              RaisedButton(
                child: Text('Start flexible update'),
                onPressed: _updateInfo?.updateAvailable == true
                    ? () {
                        InAppUpdate.startFlexibleUpdate().then((_) {
                          setState(() {
                            _flexibleUpdateAvailable = true;
                          });
                        }).catchError((e) => _showError(e));
                      }
                    : null,
              ),
              RaisedButton(
                child: Text('Complete flexible update'),
                onPressed: !_flexibleUpdateAvailable
                    ? null
                    : () {
                        InAppUpdate.completeFlexibleUpdate().then((_) {
                          _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Success!')));
                        }).catchError((e) => _showError(e));
                      },
              )
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  in_app_update: ^1.1.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:in_app_update/in_app_update.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
89
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
94
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test