Language: English | 中文

simple_update

Pub Version Platform

The simplest way to update app, support all platforms.

By default, the new version would be downloaded from avenge.app, which is a simple Version-Management-System, welcome to try ^_^

You can set your own server to publish apps.

Getting Started

  1. Register for free

    https://avenge.app/register

  2. Create app & create version

    https://avenge.app/developer/resources/app-apps/new

    https://avenge.app/developer/resources/app-versions/new

  3. Install

    dependencies:
        simple_update: ^2.0.12
    
  1. Usage

    This is an example of Android.

    In this example, you can use ota_update to update your app.

    import 'package:ota_update/ota_update.dart';
    import 'package:simple_update/simple_update.dart' as simple;
    import 'package:package_info/package_info.dart';
    
    code...
    RaisedButton(
       onPressed: () async {
         var updater = new simple.SimpleUpdate(
             appId: 1,
             appKey: 'g4rehwe8fq4qe9rgh4q123');
         var info = await PackageInfo.fromPlatform();
         var res = await updater.checkUpdate(
             platform: simple.Platform.Android,
             info: simple.Info(
                 appName: info.appName,
                 version: info.version,
                 buildNumber: int.parse(info.buildNumber)));
         if (res == true) {
           var re = await showDialog<bool>(
             context: context,
             builder: (context) => AlertDialog(
               title: Text('New version'),
               content: Text('Install the new version?'),
               actions: [
                 FlatButton(
                     onPressed: () => Navigator.pop(context),
                     child: Text('Cancel')),
                 FlatButton(
                     onPressed: () => Navigator.pop(context, true),
                     child: Text('Yes')),
               ],
             ),
           );
           if (re == true) {
             var r = await updater.update(
                 platform: simple.Platform.Android,
                 downloader: (info, version) {
                   return OtaUpdate()
                       .execute(
                     version.src,
                     destinationFilename:
                         '${info.appName}_${version.name}+${version.number}.apk',
                     sha256checksum: version.sha256,
                   )
                       .transform(StreamTransformer<OtaEvent,
                               simple.Event>.fromHandlers(
                           handleData: (event, sink) {
                     sink.add(simple.Event(
                         status: simple.Status.values[event.status.index],
                         value: event.value));
                   }));
                 });
             if (r is Stream<simple.Event>) {
               r.listen((event) {
                 switch (event.status) {
                   case simple.Status.DOWNLOADING:
                     print('downloading %${event.value}');
                     break;
                   case simple.Status.INSTALLING:
                     print('installing');
                     break;
                   case simple.Status.ALREADY_RUNNING_ERROR:
                     print('download is already running');
                     break;
                   case simple.Status.PERMISSION_NOT_GRANTED_ERROR:
                     print(
                         'could not continue because of missing permissions');
                     break;
                   case simple.Status.INTERNAL_ERROR:
                   case simple.Status.DOWNLOAD_ERROR:
                   case simple.Status.CHECKSUM_ERROR:
                     print('error ${event.value}');
                 }
               });
             }
           }
         } else {
           print('no latest version');
         }
       },
       child: Text('Update'),
    )
    code...
    

Build publish server

The default value of SimpleUpdate.apiPrefix is 'https://avenge.app/api', you can set your own server to publish apps.

   var updater = SimpleUpdate(apiPrefix: 'your own server');

When request the latest version, it should send these parameters to remote server by GET method:

https://avenge.app/api/latest?app_id=456&app_key=abc123&platform=0

platform: 0:android 1:ios 2:fuchsia 3:linux 4:windows 5:macOS

Then, the remote server will send back a json:

  {
    "code": 0,
    "message": "success",
    "data": {
     "id": 123,
     "app_id": 456,
     "platform": 0,
     "name": "1.0.1",
     "number": 24,
     "src": "file url",
     "sha256": "sha256 of file",
     "created_at": "2020-07-29 12:15:46"
    }
  }

If code is 0, it means success.

If something went wrong, it would be:

   {
     "code": -1,
     "message": "something wrong ..."
   }

All projects

PluginsStatusDescription
simple_logPub VersionThe simplest way to upload logs to remote server, support all platforms
simple_updatePub VersionThe simplest way to update your app, support all platforms

Libraries

simple_update
Support for doing something awesome. [...]