github_release_apk_updater 1.0.2 copy "github_release_apk_updater: ^1.0.2" to clipboard
github_release_apk_updater: ^1.0.2 copied to clipboard

A Flutter plugin to automatically check for, download, and install updates directly from GitHub releases.

GitHub Release APK Updater #

pub package License: MIT

A Flutter plugin for Android that enables automatic updates by fetching release information directly from a GitHub repository. It handles checking for newer versions, downloading the APK, and launching the installation process. Aditionally, it provides authentication by token to use private repositories.

Features #

  • GitHub Release Integration: Fetch latest release metadata (tag, assets, release notes).
  • Version Comparison: Built-in semantic versioning comparison between the installed app and the GitHub release.
  • Background Downloading: Downloads the APK to a secure local directory using dio.
  • Easy Installation: Launches the Android native APK installer directly from your app.
  • Customizable UI: Use the library headless to build your own update dialogs.

Getting started #

Android Setup #

  1. File Provider: You must define a FileProvider in your AndroidManifest.xml to allow the package to share the downloaded APK with the system installer.
<manifest ...>
    <application ...>
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>
    </application>
</manifest>
  1. File Paths: Create android/app/src/main/res/xml/file_paths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path name="external_files" path="." />
</paths>

Usage #

Create a GitHub tag and release #

  1. Go to your GitHub repository and navigate to the "Releases" section.
  2. Click on "Draft a new release".
  3. Fill in the release details:
    • Tag version: Use semantic versioning (e.g., v1.0.0).
    • Release title: A descriptive title for the release.
    • Description: Add release notes or changelog information.
  4. Upload your APK file as an asset by dragging and dropping it into the "Attach binaries by dropping them here or selecting them" area.
  5. Once everything is filled out, click "Publish release" to make it available.

Simple Update Flow #

import 'package:github_release_apk_updater/github_release_apk_updater.dart';

void checkForUpdates() async {
  final updater = GithubReleaseApkUpdater();
  final apiService = GitHubApiService(
    owner: 'guido-cutipa',
    repo: 'dummy-repo',
  );

  // 1. Get latest release
  final latestRelease = await apiService.getLatestRelease();
  
  // 2. Compare versions
  final currentVersion = await updater.getCurrentAppVersion();
  final hasUpdate = VersionComparator.isNewer(
    currentVersion, 
    latestRelease.tagName.replaceFirst('v', ''),
  );

  if (hasUpdate) {
    // 3. Download APK
    final downloader = ApkDownloaderService();
    final apkFile = await downloader.downloadApk(
      url: latestRelease.assets.first.browserDownloadUrl,
      fileName: 'app-update.apk',
    );

    // 4. Install
    await updater.installApk(apkFile.path);
  }
}

Example App #

  • A complete example app demonstrating the usage of the github_release_apk_updater package can be found in the [example]
  • Modify main.dart to include your GitHub repository details and run the app to see the update flow in action.
  final ownerGithub = 'guido-cutipa'; // Replace with your owner
  final repositoryGithub = 'dummy-repo'; // Replace with your repository
  final apkKeyName = '';
  dynamic tokenGithub; // optional: only needed for private repos
  • Compile and run the example app on an Android device to test the update functionality.

Additional information #

0
likes
0
points
204
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to automatically check for, download, and install updates directly from GitHub releases.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, package_info_plus, path_provider, plugin_platform_interface

More

Packages that depend on github_release_apk_updater

Packages that implement github_release_apk_updater