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
- Host: GitHub
- URL: https://github.com/merrit/self_updater
- Owner: Merrit
- License: other
- Created: 2022-07-22T18:26:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-10T20:11:03.000Z (over 3 years ago)
- Last Synced: 2025-08-19T04:48:18.365Z (7 months ago)
- Topics: flutter, updater
- Language: Dart
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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! 💙