flutter_github_releases_service 0.2.0

flutter_github_releases_service #

Use github releases to update the app.

Note: This has only been tested on Android.

install #

dependencies:
  flutter_github_releases_service:

'android\app\src\main\AndroidManifest.xml' #

See also: flutter_downloader

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.example">

    <!-- new -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <!-- new -->
    
    <application android:name="io.flutter.app.FlutterApplication" android:label="example" android:icon="@mipmap/ic_launcher">
        <activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
            <meta-data android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- new -->
        <provider android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider" android:authorities="${applicationId}.flutter_downloader.provider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
        </provider>

        <provider android:name="androidx.work.impl.WorkManagerInitializer" android:authorities="${applicationId}.workmanager-init" android:enabled="false" android:exported="false" />

        <provider android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer" android:authorities="${applicationId}.flutter-downloader-init" android:exported="false">
            <meta-data android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS" android:value="5" />
        </provider>
        <!-- new -->

    </application>
</manifest>

Usage example: #

import 'package:flutter/material.dart';
import 'package:flutter_github_releases_service/flutter_github_releases_service.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  GithubReleasesService grs = GithubReleasesService(
    owner: 'januwA',
    repo: 'flutter_anime_app',
  );
  @override
  void dispose() {
    grs.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () async {
            print('latestVersion: ' + await grs.latestVersion);
            print('localVersion: ' + await grs.localVersion);
            print(await grs.isNeedUpdate);

            if (await grs.isNeedUpdate) {
              try {
                grs.downloadApk(
                  downloadUrl: grs.latestSync.assets.first.browserDownloadUrl,
                  apkName: grs.latestSync.assets.first.name,
                );
              } catch (e) {
                print('安装失败: $e');
              }
            }
          },
          child: Text('Test'),
        ),
      ),
    );
  }
}

[0.2.0] - 2019-8-20

  • 优化代码
  • 增加sync属性调用

[0.1.0] - 2019-8-8

  • Use github releases to update the app.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_github_releases_service: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_github_releases_service/flutter_github_releases_service.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/dto/github_releases/serializers.dart.

Run flutter format to format lib/dto/github_releases/serializers.dart.

Format lib/flutter_github_releases_service.dart.

Run flutter format to format lib/flutter_github_releases_service.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
built_collection ^4.2.2 4.2.2
built_value ^6.7.0 6.7.0
flutter 0.0.0
flutter_downloader ^1.1.9 1.1.9
http ^0.12.0+2 0.12.0+2
install_plugin ^2.0.1 2.0.1
package_info ^0.4.0+6 0.4.0+6
path ^1.6.4 1.6.4
path_provider ^1.2.0 1.2.0
permission_handler ^3.2.1+1 3.2.2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11 1.14.12
fixnum 0.10.9
http_parser 3.1.3
matcher 0.12.5
meta 1.1.6 1.1.7
pedantic 1.8.0+1
quiver 2.0.5
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner any
built_value_generator any
test any