An open API service indexing awesome lists of open source software.

https://github.com/merrit/self_updater

A self updater for Flutter apps
https://github.com/merrit/self_updater

flutter updater

Last synced: 7 months ago
JSON representation

A self updater for Flutter apps

Awesome Lists containing this project

README

          

A self updater for Flutter apps

## Platform Support

| Linux | macOS | Windows |
| :---: | :---: | :-----: |
| ✔️ | ❌ | ✔️ |

## Features

Automatically download the lastest release from GitHub releases for the running
platform, close the running app, update, relaunch app.

## Getting started

Add to `pubspec.yaml`

```yml
self_updater:
git:
url: https://github.com/Merrit/self_updater.git
ref:
```

## Usage

Basic example, this implementation would be better off in something like a
function elsewhere.

```dart
void main() {
WidgetsFlutterBinding.ensureInitialized();

// runApp()

updateApp();
}

Future updateApp() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();

Updater updater = await Updater.initialize(
currentVersion: packageInfo.version,
updateChannel: UpdateChannel.stable,
repoUrl: 'https://github.com//',
);

if (!updater.updateAvailable) return;

String? updateArchivePath = await updater.downloadUpdate();
if (updateArchivePath == null) {
print('Downloading update was NOT successful.');
} else {
await updater.installUpdate(
archivePath: updateArchivePath,
relaunchApp: true,
);
}
}
```

## Additional information

Updater is only tested for Development releases so far.

The updater currently only supports updates from GitHub releases, that adhere to
Semver versioning as well as releases tagged `latest` for updating to
development releases. (Development releases currently require a file called
`BUILD` in the app directory with the UTC timestamp of when it was built.)

An in-development app that uses the updater can be seen here:
https://github.com/Merrit/adventure_list

This package has been created primarily for the author's needs, however if it is
found to be useful contributions, issues, ideas, etc are very welcome! 💙