Updat – 简单易用的 Flutter 桌面更新包

Logo

Updat 是一个简单易用、可靠的 Flutter 原生更新器,可处理您的应用程序更新。您只需要一个托管文件的地方和一个检查最新版本的地方。

演示

demo

安装

要开始,只需在终端输入 flutter pub add updat

? 搞定,就是这么简单。

入门

与您的应用程序集成只需要几行代码,在您希望 Updat 小部件显示的位置添加以下小部件:

UpdatWidget(
  currentVersion: "1.0.0",
  getLatestVersion: () async {
    // Here you should fetch the latest version. It must be semantic versioning for update detection to work properly.
    return "1.0.1";
  },
  getBinaryUrl: (latestVersion) async {
    // Here you provide the link to the binary the user should download. Make sure it is the correct one for the platform!
    return "https://github.com/latest/release/bin.exe";
  },
  // Lastly, enter your app name so we know what to call your files.
  appName: "Updat Example",
),

只需几秒钟即可让您开始使用 ⚡️。

配置

可用的 Updat 参数

参数 类型 Value 默认值
currentVersion 字符串 必需。必须是语义化版本。这是当前软件包的版本。 不适用
getLatestVersion Future<String> 必需。必须是语义化版本。此项应向服务器请求最新版本 不适用
getBinaryUrl Future<String> 必需。此项应提供下载特定应用程序版本二进制文件的链接。参数:latestVersion 不适用
appNme 字符串 必需。应用程序的名称。用于下载时命名二进制文件。 不适用
getChangelog Future<String> 这将渲染一个纯文本格式的更新日志。 不适用
callback void Function(UpdatStatus) UpdatStatus 更新时调用的回调。 不适用
getDownloadFileLocation Future<File> 选择更新下载的位置。 不适用
updateChipBuilder Widget Function(...) 覆盖默认的更新卡片。 不适用
updateDialogBuilder Widget Function(...) 覆盖默认的更新对话框。 不适用
openOnDownload 布尔值 下载完成后是否自动打开安装程序。
closeOnInstall 布尔值 下载完成后是否自动关闭应用程序。

主题化

Updat 非常容易主题化。我们也内部使用了 updateChipBuilderupdateDialogBuilder 来设计我们的组件,所以您拥有与我们相同的可定制性。我们提供了一些主题供您入门。

要更改主题,只需将所需的主题添加到构建器中即可。

芯片

  • defaultChip,这是一个仅在有可用更新时显示的 ElevatedButton。默认显示。

  • defaultChipWithCheckFor,这是一个在所有条件下都显示的 ElevatedButton,允许重新检查更新。

  • flatChip,这是一个仅在有可用更新时显示的 TextButton

  • flatChipWithCheckFor,这是一个在所有条件下都显示的 TextButton,允许重新检查更新。

对话框

  • default,这是默认的 M2 和 M3 对话框,默认显示。

GitHub

查看 Github