• Stars
    star
    274
  • Rank 150,274 (Top 3 %)
  • Language
    C++
  • License
    MIT License
  • Created about 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This plugin allows Flutter desktop apps to automatically update themselves (based on sparkle and winsparkle).

auto_updater

pub version

This plugin allows Flutter desktop apps to automatically update themselves (based on sparkle and winsparkle).


English | 简体中文


Platform Support

Linux macOS Windows
✔️ ✔️

Quick Start

Installation

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

dependencies:
  auto_updater: ^0.1.7

Or

dependencies:
  auto_updater:
    git:
      url: https://github.com/leanflutter/auto_updater.git
      ref: main

⚠️ Windows requirements

  • openssl

Run the following command:

Use Chocolatey

choco install openssl

Usage

import 'package:auto_updater/auto_updater.dart';

void main() async {
  // Must add this line.
  WidgetsFlutterBinding.ensureInitialized();

  String feedURL = 'http://localhost:5002/appcast.xml';
  await autoUpdater.setFeedURL(feedURL);
  await autoUpdater.checkForUpdates();
  await autoUpdater.setScheduledCheckInterval(3600);

  runApp(MyApp());
}

Please see the example app of this plugin for a full example.

Publish your app

Generate private key

Run the following command:

dart run auto_updater:generate_keys

You need to run this command on macOS and Windows systems separately.

macOS

Prepare signing with EdDSA signatures:

Output:

A key has been generated and saved in your keychain. Add the `SUPublicEDKey` key to
the Info.plist of each app for which you intend to use Sparkle for distributing
updates. It should appear like this:

    <key>SUPublicEDKey</key>
    <string>pfIShU4dEXqPd5ObYNfDBiQWcXozk7estwzTnF9BamQ=</string>

Change the file macos/Runner/Info.plist as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

  ...

+	<key>SUPublicEDKey</key>
+	<string>bHaXClrRGMmKoKP/3HJnr/jn2ODTRPAM3VZhhkI9ZvY=</string>
</dict>
</plist>
Windows

Prepare signing with DSA signatures:

Output:

Generated two files:
dsa_priv.pem: your private key. Keep it secret and don't share it!
dsa_pub.pem: public counterpart to include in youe app.
BACK UP YOUR PRIVATE KEY AND KEEP IT SAFE!
If you lose it, your users will be unable to upgrade!

command will generate the private key (dsa_priv.pem) and the public key (dsa_pub.pem) for you. Please Back up your private key and keep it safe, Add your public key to your project either as Windows resource.

Change the file windows/runner/Runner.rc as follows:

...

+/////////////////////////////////////////////////////////////////////////////
+//
+// WinSparkle
+//

+// And verify signature using DSA public key:
+DSAPub      DSAPEM      "../../dsa_pub.pem"

Packaging

To simplify the packaging process, Flutter Distributor is used here, A complete tool dedicated to packaging and publishing Flutter apps.

Add distribute_options.yaml to your project root directory.

output: dist/
releases:
  - name: dev
    jobs:
      - name: release-macos
        package:
          platform: macos
          target: zip
          build_args:
            dart-define:
              APP_ENV: dev
      # See full documentation: https://distributor.leanflutter.org/configuration/makers/exe
      - name: release-windows
        package:
          platform: windows
          target: exe
          build_args:
            dart-define:
              APP_ENV: dev
macOS

Run the following command:

flutter_distributor release --name dev --jobs release-macos
Windows

Run the following command:

flutter_distributor release --name dev --jobs release-windows

Get signature

macOS

Run the following command:

dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-macos.zip

Output:

sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA==" length="13400992"

Update the obtained new signature to the value of the sparkle:edSignature attribute of the enclosure node of the appcast.xml file.

Windows

Run the following command:

dart run auto_updater:sign_update dist/1.1.0+2/auto_updater_example-1.1.0+2-windows-setup.exe

Output:


sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk=" length="13400992"

Update the obtained new signature to the value of the sparkle:dsaSignature attribute of the enclosure node of the appcast.xml file.

Distributing

Add appcast.xml to your project dist/ directory.

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">
    <channel>
        <title>auto_updater_example</title>
        <description>Most recent updates to auto_updater_example</description>
        <language>en</language>
        <item>
            <title>Version 1.1.0</title>
            <sparkle:releaseNotesLink>
                https://your_domain/your_path/release_notes.html
            </sparkle:releaseNotesLink>
            <pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate>
            <enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-macos.zip"
                       sparkle:edSignature="pbdyPt92pnPkzLfQ7BhS9hbjcV9/ndkzSIlWjFQIUMcaCNbAFO2fzl0tISMNJApG2POTkZY0/kJQ2yZYOSVgAA=="
                       sparkle:version="1.1.0"
                       sparkle:os="macos"
                       length="13400992"
                       type="application/octet-stream" />
        </item>
        <item>
            <title>Version 1.1.0</title>
            <sparkle:releaseNotesLink>
                https://your_domain/your_path/release_notes.html
            </sparkle:releaseNotesLink>
            <pubDate>Sun, 16 Feb 2022 12:00:00 +0800</pubDate>
            <enclosure url="1.1.0+2/auto_updater_example-1.1.0+2-windows.exe"
                       sparkle:dsaSignature="MEUCIQCVbVzVID7H3aUzAY5znpi+ySZKznkukV8whlMFzKh66AIgREUGOmvavlcg6hwAwkb2o4IqVE/D56ipIBshIqCH8rk="
                       sparkle:version="1.1.0+2"
                       sparkle:os="windows"
                       length="0"
                       type="application/octet-stream" />
        </item>
    </channel>
</rss>

This example uses the same appcast.xml file for macOS and Windows, and you need to configure the value of the sparkle:os property accordingly.

Start the test update server:

cd dist/
serve -l 5002

Troubleshooting

macOS

  • Make sure you have the sparkle pod added as described in Sparkle Documentation
  • Make sure you have added and enabled network capabilties of your app and disabled the sandbox for release by adding the following to your entitlement files for debug and release
<key>com.apple.security.network.client</key>
  <true/>
<key>com.apple.security.network.server</key>
  <true/>
<key>com.apple.security.app-sandbox</key>
  <false/>

Who's using it?

  • Biyi - A convenient translation and dictionary app.

API

AutoUpdater

Methods

setFeedURL

Sets the url and initialize the auto updater.

checkForUpdates

Asks the server whether there is an update. You must call setFeedURL before using this API.

setScheduledCheckInterval

Sets the auto update check interval, default 86400, minimum 3600, 0 to disable update

Related Links

License

MIT

More Repositories

1

awesome-flutter-desktop

A curated list of awesome things related to Flutter desktop.
1,509
star
2

flutter_distributor

An all-in-one Flutter application packaging and distribution tool, providing you with a one-stop solution to meet various distribution needs.
Dart
781
star
3

window_manager

This plugin allows Flutter desktop apps to resizing and repositioning the window.
C++
678
star
4

widget-livebook

Live preview example for flutter widgets.
Dart
611
star
5

flutter_flipperkit

Flipper (Extensible mobile app debugger) for flutter.
Java
359
star
6

tray_manager

This plugin allows Flutter desktop apps to defines system tray.
C++
223
star
7

hotkey_manager

This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).
Dart
131
star
8

.github

96
star
9

launch_at_startup

This plugin allows Flutter desktop apps to Auto launch on startup / login.
C++
87
star
10

screen_capturer

This plugin allows Flutter desktop apps to capture screenshots.
C++
80
star
11

protocol_handler

This plugin allows Flutter apps to register and handle custom protocols (i.e. deep linking).
C++
75
star
12

contextual_menu

This plugin allows Flutter desktop apps to create native context menus.
C++
74
star
13

local_notifier

This plugin allows Flutter desktop apps to notify local notifications.
C++
69
star
14

screen_text_extractor

This plugin allows Flutter desktop apps to extract text from screen.
C++
52
star
15

clipboard_watcher

This plugin allows Flutter apps to watch clipboard changes.
C++
50
star
16

screen_retriever

This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.
C++
45
star
17

flipper-plugin-reduxinspector

Redux Inspector for flipper (Extensible mobile app debugger).
JavaScript
42
star
18

anyinspect_app

AnyInspect desktop app.
Dart
41
star
19

flutter_apps

A collection of apps built on Flutter.
Dart
41
star
20

flutter_flipperkit_plugins

Plugins for flutter flipperkit.
Dart
33
star
21

uni_links_desktop

A desktop (supports macOS and Windows) implementation of uni_links plugin.
C++
28
star
22

keypress_simulator

This plugin allows Flutter desktop apps to simulate key presses.
C++
27
star
23

flutter_tencent_captcha

适用于 Flutter 的腾讯云验证码插件
Java
26
star
24

uni_translate

A universal translate client.
Dart
21
star
25

flutter_aliyun_captcha

适用于 Flutter 的阿里云滑动验证插件
Dart
20
star
26

uni_ocr

A universal ocr client.
Dart
18
star
27

influxui

A fully featured Flutter widgets library, Inspired by mantine.
Dart
16
star
28

flutter_svprogresshud

A clean and lightweight progress HUD for flutter app.
Objective-C
16
star
29

flutter_superplayer

适用于 Flutter 的腾讯云超级播放器插件
Java
14
star
30

shortcut_menu_extender

This plugin allows Flutter apps to Extending global shortcut menus.
C++
12
star
31

makeanyicon

A configurable icon maker.
Dart
11
star
32

vclibs

Let your flutter windows apps include vclibs.
C++
11
star
33

storybook_dart

Storybook for Flutter, build your Flutter widgets storybook using storybookjs.
Dart
11
star
34

anyinspect

AnyInspect is a tool for debugging your Flutter apps.
Dart
10
star
35

flutter_qiyu

适用于 Flutter 的七鱼客服插件
Objective-C
9
star
36

flutter_photo_picker

Photo Picker plugin for Flutter.
Swift
9
star
37

awesome-flutter-mobile

A curated list of awesome things related to Flutter mobile.
9
star
38

flutter_txugcupload

适用于 Flutter 的腾讯云点播上传 SDK
Objective-C
7
star
39

menu_base

Dart
5
star
40

flutter_yunpian_captcha

适用于 Flutter 的云片行为验证插件
Java
5
star
41

sync2gitee

LeanFlutter - To make the flutter even simpler
5
star
42

flipper-plugin-dbbrowser

Database Browser for flipper (Extensible mobile app debugger).
JavaScript
4
star
43

preference_list

Simplifies building preference pages with flexibility and ease-of-use.
Dart
4
star
44

any_icon_maker

A configurable icon maker.
Dart
4
star
45

anyinspect_web

AnyInspect website.
TypeScript
3
star
46

embed_web_pkgs

Dart
3
star
47

flutter_flipperkit_examples

Examples for flutter flipperkit.
Dart
3
star
48

anyinspect_plugins

Plugins for AnyInspect
Dart
3
star
49

flutter_desktop_examples

C++
2
star
50

leanflutter_snippets

Dart
2
star
51

awesome_list_maker

A awesome list maker
Dart
2
star
52

website

LeanFlutter web site
Astro
2
star
53

flutter_universal_boilerplate

Dart
1
star
54

base_orm

Dart
1
star
55

flutter_distributor_docs_zh

1
star
56

harmonic

Dart
1
star
57

flutter_yidun_captcha

适用于 Flutter 的网易易盾行为式验证码插件
Java
1
star
58

anyinspect_integrate_example

C++
1
star
59

openai-api-bridge

TypeScript
1
star
60

analyzeanyapp

1
star
61

all_sponsors_maker

Dart
1
star
62

mostly_reasonable_lints

A mostly reasonable set of lints for Dart and Flutter projects.
Dart
1
star