搜索插件、代码仓与 APP 分类

插件详情v1.0.0

flutter_autoupdate

轻松为您的 Flutter 应用添加自动更新功能

AndroidiOSmacOS
近 30 天下载
203
喜欢数
44
Pub 分数
120

安装插件

flutter pub add flutter_autoupdate

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

flutter_autoupdate 是一个 Flutter 包,可简化在移动和桌面应用程序中集成自动更新功能。它使应用程序能够检查更新、在后台下载更新,并无缝提示用户安装新版本。该包专为 Android、iOS 和 macOS 设计,支持应用商店和直接分发模式。该包处理版本比较、更新可用性检测,并提供可自定义的更新对话框。开发者可以使用极少的代码轻松实现强大的更新工作流。非常适合需要频繁发布新功能或安全补丁的应用。

适合场景

  • 生产应用中的自动应用更新
  • 版本升级期间的无缝用户体验
  • 后台更新检查,不会中断工作流程
  • 支持包括 iOS 和 macOS 在内的多个平台
  • 强制执行最低要求的应用版本
  • 减少手动更新提示

主要特点

  • 实时更新检查
  • 可自定义的更新对话框
  • 后台下载支持
  • 跨平台兼容性
  • 版本比较逻辑
  • 与应用商店和直接下载的集成

适合对象

  • 开发跨平台 Flutter 应用的开发者
  • 需要自动化发布管理的团队
  • 需要频繁更新的应用
  • 具有严格版本控制策略的项目
  • 面向全球用户的移动和桌面应用程序

使用建议

  • 每个平台都需要正确配置
  • 可能需要对企业和侧载应用进行额外处理
  • 更新行为取决于应用商店政策
  • 必须授予网络权限
  • 用户同意可能需要用于自动下载
  • 不适用于有严格离线要求的应用程序

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

flutter_updater

This library allows you to easily add auto-update functionality to your Android, iOS, and Windows Flutter application.

Our use case was to update the app by launching the App Store on iOS or install/execute the Android APK or Windows executable; thus, this package was born. To use this package, you should adhere to the format of the Version Template below.

Features

  • Fetch updates from iTunes App Store/remote URL
  • Launch App Store
  • Download functionality with progress
  • SHA512 hash checksum on download

Installation

Run the following command

flutter pub add flutter_autoupdate

Import the package

import 'package:flutter_autoupdate/flutter_autoupdate.dart';

Add the following to your Android app.

  • AndroidManifest.xml
<!-- Provider -->
<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>
  • android/app/src/main/res/xml/file_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path path="Android/data/<package name>/" name="files_root" />
    <external-path path="." name="external_storage_root" />
</paths>

Update the <package name> to your app package name

Examples

import 'package:flutter_updater/flutter_autoupdate.dart';

// Android/Windows
var updater = UpdateManager(versionUrl: 'versionUrl');

// iOS
var updater = UpdateManager(appId: 1500009417, countryCode: 'my');

// App Store country code, this flag is optional and only applies to iOS
var result = await updater.fetchUpdates();
print(result?.latestVersion);
print(result?.downloadUrl);
print(result?.releaseNotes);
print(result?.releaseDate);
 
if (result?.latestVersion > Version.parse('1.0.0')) {
  // Get update stream controller
  var update = await result?.initializeUpdate();
  update?.stream.listen((event) async {
    // You can build a download progressbar from the data available here
    print(event.receivedBytes);
    print(event.totalBytes);
    if (event.completed) {
      print('Download completed');

      // Close the stream controller
      await update.close();

      // On Windows, autoExit and exitDelay flag are supported.
      // On iOS, this will attempt to launch the App Store from the appId provided
      // On Android, this will simply attempt to install the downloaded APK
      await result?.runUpdate(event.path, autoExit: true, exitDelay: 5000);
    }
  });
}

For more information, check out the examples.

Version Template

By default, it will select the first index as the latest version. For more examples, sample.json is available for reference.

Android
[
  {
    "version": "3.0.0",
    "url": "https://storage.googleapis.com/download-dev.feedmepos.com/android/feedme-pos-3.0.0-beta.5.apk",
    "releaseNotes": "New update 3.0.0!",
    "releaseDate": "2021-07-28T11:58:25Z",
    "sha512": "2e0349c1e729eac0f4cb9f831fa1130241743c8db9e115013091dbeec6b8b86dc18c62bcbfab516033869c8ec8c8967615c622303d4bee62640c3b507051aca2"
  },
  {
    "version": "1.4.5",
    "url": "https://storage.googleapis.com/download-dev.feedmepos.com/android/feedme-pos-1.4.5.apk",
    "releaseNotes": "New update 1.4.5!",
    "releaseDate": "2021-06-16T11:58:25Z",
    "sha512": "f028475ad562f9f9566213774b02e0bd3ac2198899222687613937791307ec5d326cfb79ee2882273bffd6777f9c76371d6b2eed7d46e326fd687bc95e2edb2a"
  }
]
Windows
[
  {
    "version": "2.5.0",
    "url": "https://storage.googleapis.com/download-dev.feedmepos.com/feedme_sample.exe",
    "releaseNotes": "New update 2.5.0!",
    "releaseDate": "2021-07-28T11:58:25Z",
    "sha512": "53d4cc95ad07470b53b3f9bc010ab8c6776f2bc2f9f3115b0807ecebcc34175f530d02e549c260112ad08c2c86a8b92d7e7f11308df0406422be8ceea76a9190"
  }
]
iOS

It supports fetching updates by app id using the official iTunes Search API.

Contributing

We welcome the community to submit pull requests.

Bugs

  • Unable to install APK automatically after enabling "Install from unknown sources" from prompt

所属分类

依赖

依赖清单 6 项

源码仓库

使用此插件的项目

暂无相关数据。