install_plugin 1.0.0

  • Example
  • Installing
  • Versions
  • 91

install_plugin #

A flutter plugin for install apk for android; and using url to go to app store for iOS.

Usage #

To use this plugin, add install_plugin as a dependency in your pubspec.yaml file.

  /// for Android : install apk by its file absolute path;
  /// if the target platform is higher than android 24:
  /// a [appId] is required
  /// (the caller's applicationId which is defined in build.gradle)
  static Future<String> installApk(String filePath, String appId) async {
    Map<String, String> params = {'filePath': filePath, 'appId': appId};
    return await _channel.invokeMethod('installApk', params);

  /// for iOS: go to app store by the url
  static Future<String> gotoAppStore(String urlString) async {
    Map<String, String> params = {'urlString': urlString};
    return await _channel.invokeMethod('gotoAppStore', params);

Example #

For Android, you may need to request permission for READ_EXTERNAL_STORAGE to read the apk file. In the example, I used the permission_handler plugin.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:install_plugin/install_plugin.dart';
import 'package:permission_handler/permission_handler.dart';

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  String _appUrl = '';
  String _apkFilePath = '';

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        body: new Column(
          children: <Widget>[
              decoration: InputDecoration(
                      'apk file path to install. Like /storage/emulated/0/demo/update.apk'),
              onChanged: (path) => _apkFilePath = path,
                onPressed: () {
                child: Text('install')),
                  InputDecoration(hintText: 'URL for app store to launch'),
              onChanged: (url) => _appUrl = url,
                onPressed: () => onClickGotoAppStore(_appUrl),
                child: Text('gotoAppStore'))

  void onClickInstallApk() async {
    if (_apkFilePath.isEmpty) {
      print('make sure the apk file is set');
    Map<PermissionGroup, PermissionStatus> permissions =
        await PermissionHandler().requestPermissions([]);
    if (permissions[] == PermissionStatus.granted) {
      InstallPlugin.installApk(_apkFilePath, 'com.zaihui.installpluginexample')
          .then((result) {
        print('install apk $result');
      }).catchError((error) {
        print('install apk error: $error');
    } else {
      print('Permission request fail!');

  void onClickGotoAppStore(String url) {
    url = url.isEmpty
        ? ''
        : url;

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

0.0.1 #

  • Add installApk function for android to install apk, supporting ANDROID.O.
  • Add gotoAppStore function for iOS to launch a url to App Store.

0.0.2 #

  • Fix the bug that Pixel Device install apk fail.
  • Optimize the user experience when app asking for Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES permission for Android device above ANDROID.O.

1.0.0 #

  • Remove unused code.
  • Update plugin homepage url.


install_plugin_example #

Demonstrates how to use the install_plugin plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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

  install_plugin: ^1.0.0

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:install_plugin/install_plugin.dart';
Version Uploaded Documentation Archive
2.0.1 May 16, 2019 Go to the documentation of install_plugin 2.0.1 Download install_plugin 2.0.1 archive
2.0.0 Mar 28, 2019 Go to the documentation of install_plugin 2.0.0 Download install_plugin 2.0.0 archive
1.2.0 Feb 14, 2019 Go to the documentation of install_plugin 1.2.0 Download install_plugin 1.2.0 archive
1.0.0 Dec 11, 2018 Go to the documentation of install_plugin 1.0.0 Download install_plugin 1.0.0 archive
0.0.2 Sep 25, 2018 Go to the documentation of install_plugin 0.0.2 Download install_plugin 0.0.2 archive
0.0.1 Sep 23, 2018 Go to the documentation of install_plugin 0.0.1 Download install_plugin 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8