version_check 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

version_check #

Check iOS/Android/Mac store app version and provide update alert if neccessary.

Usage #

import 'package:version_check/version_check.dart';

  final versionCheck = VersionCheck();

  @override
  void initState() {
    super.initState();
    checkVersion();
  }

  Future checkVersion() async {
    await versionCheck.checkVersion(context);
  }

[0.1.1] - 2020/05/21 #

  • getStoreVersionAndUrl can be passed to constructor to override fetching version and url info.
  • showUpdateDialog can be passed to constructor to override update dialog.

[0.1.0] - 2020/05/21 #

  • Initial release.

example/lib/main.dart

import 'dart:io';

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'version_check demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'version_check demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String version = '';
  String storeVersion = '';
  String storeUrl = '';
  String packageName = '';
  @override
  void initState() {
    super.initState();
    checkVersion();
  }

  final versionCheck = VersionCheck(
    packageName: Platform.isIOS
        ? 'com.tachyonfactory.iconFinder'
        : 'com.tachyonfactory.icon_finder',
    packageVersion: '1.0.1',
    showUpdateDialog: customShowUpdateDialog,
  );

  Future checkVersion() async {
    await versionCheck.checkVersion(context);
    setState(() {
      version = versionCheck.packageVersion;
      packageName = versionCheck.packageName;
      storeVersion = versionCheck.storeVersion;
      storeUrl = versionCheck.storeUrl;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'packageVersion = $version',
            ),
            Text(
              'storeVersion = $storeVersion',
            ),
            Text(
              'storeUrl = $storeUrl',
            ),
            Text(
              'packageName = $packageName',
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.store),
        onPressed: () async {
          await versionCheck.launchStore();
        },
      ),
    );
  }
}

void customShowUpdateDialog(BuildContext context, VersionCheck versionCheck) {
  showDialog(
    context: context,
    barrierDismissible: false,
    child: AlertDialog(
      title: Text('NEW Update Available'),
      content: SingleChildScrollView(
        child: ListBody(
          children: <Widget>[
            Text(
                'Do you REALLY want to update to ${versionCheck.storeVersion}?'),
            Text('(current version ${versionCheck.packageVersion})'),
          ],
        ),
      ),
      actions: <Widget>[
        FlatButton(
          child: Text('Update'),
          onPressed: () async {
            await versionCheck.launchStore();
            Navigator.of(context).pop();
          },
        ),
        FlatButton(
          child: Text('Close'),
          onPressed: () {
            Navigator.of(context).pop();
          },
        ),
      ],
    ),
  );
}

Use this package as a library

1. Depend on it

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


dependencies:
  version_check: ^0.1.1

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:version_check/version_check.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:version_check/version_check.dart that imports:
  • package:package_info/package_info.dart that declares support for platforms: android, ios, macos

Package does not support Flutter platform web

Because:

  • package:version_check/version_check.dart that imports:
  • package:package_info/package_info.dart that declares support for platforms: android, ios, macos

Package does not support Flutter platform windows

Because:

  • package:version_check/version_check.dart that imports:
  • package:url_launcher/url_launcher.dart that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

Because:

  • version_check that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
html ^0.14.0+3 0.14.0+3
http ^0.12.1 0.12.1
package_info ^0.4.0+18 0.4.1
url_launcher ^5.4.7 5.5.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
csslib 0.16.1
flutter_web_plugins 0.0.0
http_parser 3.1.4
meta 1.1.8 1.2.2
path 1.7.0
pedantic 1.9.0 1.9.2
platform_detect 1.4.0
plugin_platform_interface 1.0.2
pub_semver 1.4.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
url_launcher_linux 0.0.1+1
url_launcher_macos 0.0.1+7
url_launcher_platform_interface 1.0.7
url_launcher_web 0.1.2
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test