Search packages, repositories and app categories

Package detailsv2.1.0

install_plugin

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

AndroidiOS
30-day downloads
13.4K
Likes
79
Pub points
150

Install package

flutter pub add install_plugin

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The install_plugin is a Flutter package that enables Android apps to install APK files directly, facilitating seamless app updates or installations. For iOS, it redirects users to the App Store via a provided URL, ensuring compatibility with Apple's distribution policies. Designed for app update scenarios, it simplifies the process of delivering new versions without requiring users to manually download from external sources. The plugin supports both Android and iOS platforms, offering a cross-platform solution for managing app installation workflows. It integrates easily via pub.dev and includes open-source code for transparency and customization.

Use cases

  • App auto-update feature
  • Direct APK installation on Android
  • Redirecting iOS users to App Store
  • Bundled app distribution
  • In-app update prompts
  • Offline app installation

Key features

  • Android APK installation
  • iOS App Store redirection
  • Cross-platform support
  • Simple integration via pub.dev
  • Open-source codebase
  • URL-based iOS navigation

Suitable for

  • Developers building self-updating apps
  • Apps requiring offline installation
  • Projects distributing custom APKs
  • Mobile apps with in-app update logic
  • Teams needing transparent update mechanisms

Considerations

  • Requires Android permissions for APK installation
  • iOS only supports App Store redirects
  • APK installation requires user permission on Android
  • Not suitable for official App Store submissions
  • Limited to Android and iOS platforms
  • Security risks with untrusted APK sources

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

install_plugin

Build Status pub package license

We use the install_plugin plugin to 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 example:

dependencies:
  install_plugin: '^2.1.0'

iOS

Your project need create with swift.

Android

You need to request permission for READ_EXTERNAL_STORAGE to read the apk file. You can handle the storage permission using flutter_permission_handler.

 <!-- read permissions for external storage -->
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

In Android version >= 8.0 , You need to request permission for REQUEST_INSTALL_PACKAGES to install the apk file

<!-- installation package permissions -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

In Android version <= 6.0 , You need to request permission for WRITE_EXTERNAL_STORAGE to copy the apk from the app private location to the download directory

<!-- write permissions for external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Example

install apk from the internet

  _networkInstallApk() async {
    if (_progressValue != 0 && _progressValue < 1) {
      _showResMsg("Wait a moment, downloading");
      return;
    }

    _progressValue = 0.0;
    var appDocDir = await getTemporaryDirectory();
    String savePath = appDocDir.path + "/takeaway_phone_release_1.apk";
    String fileUrl =
        "https://s3.cn-north-1.amazonaws.com.cn/mtab.kezaihui.com/apk/takeaway_phone_release_1.apk";
    await Dio().download(fileUrl, savePath, onReceiveProgress: (count, total) {
      final value = count / total;
      if (_progressValue != value) {
        setState(() {
          if (_progressValue < 1.0) {
            _progressValue = count / total;
          } else {
            _progressValue = 0.0;
          }
        });
        print((_progressValue * 100).toStringAsFixed(0) + "%");
      }
    });

    final res = await InstallPlugin.install(savePath);
    _showResMsg(
        "install apk ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
  }

install apk from the local storage

  _localInstallApk() async {
    FilePickerResult? result = await FilePicker.platform.pickFiles();
    if (result != null) {
      final res = await InstallPlugin.install(result.files.single.path ?? '');
      _showResMsg(
          "install apk ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
    } else {
      // User canceled the picker
      _showResMsg("User canceled the picker apk");
    }
  }

Go to AppStore , example appStore url : https://itunes.apple.com/cn/app/%E5%86%8D%E6%83%A0%E5%90%88%E4%BC%99%E4%BA%BA/id1375433239?l=zh&ls=1&mt=8

  _gotoAppStore(String url) async {
    url = url.isEmpty ? _defaultUrl : url;
    final res = await InstallPlugin.install(url);
    _showResMsg(
        "go to appstroe ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
  }

Categories

Source repository

Projects using this package