flutter_prince_of_versions 2.0.1
flutter_prince_of_versions: ^2.0.1 copied to clipboard

Library for easier versioning of your applications. You can check for updates from a remote server, Google Play or App Store.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_prince_of_versions/flutter_prince_of_versions.dart';

import 'my_callback.dart';

void main() {
  runApp(MaterialApp(home: Scaffold(body: MyApp())));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  static const androidUrl = 'https://pastebin.com/raw/FBMxHpN7';
  static const iOSUrl = 'https://pastebin.com/raw/0MfYmWGu';

  Future<void> _checkForUpdates() async {
    String url = Platform.isAndroid ? androidUrl : iOSUrl;

    try {
      final updateData = await FlutterPrinceOfVersions.checkForUpdates(
        url: url,
        requirementChecks: {
          'region': (value) {
            return value == 'hr';
          },
          'bluetooth': (value) {
            return value == '5.0';
          }
        },
      );

      print('Update status: ${updateData.status}');
      print('Installed version: ${updateData.updateInfo.installedVersion}');
      print('Last version: ${updateData.updateInfo.lastVersionAvailable}');
      print('Metadata: ${updateData.metadata}');
    } catch (error) {
      print(error);
    }
  }

  Future<void> _checkForUpdatesFromAppStore() async {
    final updateData =
        await FlutterPrinceOfVersions.checkForUpdatesFromAppStore();
    print('Update status: ${updateData.status}');
    print('Current version: ${updateData.version}');
  }

  Future<void> _checkForUpdatesFromGooglePlay() async {
    final callback = MyCallback(context);
    await FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay(
        "Google Play url", callback);
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Column(
        children: <Widget>[
          SizedBox(height: 100),
          Center(
            child: Text(
              'Prince of Versions example',
              style: TextStyle(fontSize: 24),
            ),
          ),
          SizedBox(height: 40),
          CupertinoButton.filled(
            child: Text('Check for updates'),
            onPressed: _checkForUpdates,
          ),
          SizedBox(height: 20),
          CupertinoButton.filled(
            child: Text('Check App Store updates'),
            onPressed: _checkForUpdatesFromAppStore,
          ),
          SizedBox(height: 20),
          CupertinoButton.filled(
            child: Text('Check Google Play updates'),
            onPressed: _checkForUpdatesFromGooglePlay,
          ),
        ],
      ),
    );
  }
}
5
likes
120
pub points
45%
popularity

Publisher

infinum.com

Library for easier versioning of your applications. You can check for updates from a remote server, Google Play or App Store.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_prince_of_versions