flutter_prince_of_versions 1.0.6 copy "flutter_prince_of_versions: ^1.0.6" to clipboard
flutter_prince_of_versions: ^1.0.6 copied to clipboard

outdated

Prince of Versions is a plugin which checks for application updates using configuration from some resource (Remote server, Google Play Store 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> {
  String androidUrl = 'https://pastebin.com/raw/FBMxHpN7';
  String iOSUrl = 'https://pastebin.com/raw/0MfYmWGu';

  @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: () async {
                String url = Platform.isAndroid ? androidUrl : iOSUrl;

                dynamic data;
                try {
                  data = await FlutterPrinceOfVersions.checkForUpdates(
                    url: url,
                    shouldPinCertificates: false,
                  );
                } catch (error) {
                  print(error);
                  // do something on error
                }
                print('Update status: ${data.status.toString()}');
                print('Current version: ${data.updateInfo.installedVersion}');
                print('Last available major version: ${data.updateInfo.lastVersionAvailable.major}');
                print(data.meta.metadata);
              }),
          SizedBox(height: 20),
          CupertinoButton.filled(
              child: Text('App Store test'),
              onPressed: () async {
                final data = await FlutterPrinceOfVersions.checkForUpdatesFromAppStore(
                    trackPhasedRelease: true, notifyOnce: false);
                print('Update status: ${data.status.toString()}');
                print('Current version: ${data.version.major}');
              }),
          SizedBox(height: 20),
          CupertinoButton.filled(
              child: Text('Play Store test'),
              onPressed: () async {
                final Callback callback = MyCallback(context);
                await FlutterPrinceOfVersions.checkForUpdatesFromGooglePlay(
                    "http://pastebin.com/raw/QFGjJrLP", callback);
              }),
        ],
      ),
    );
  }

  void showAlert(String title, String content) {
    showDialog<bool>(
      context: context,
      builder: (BuildContext context) {
        return CupertinoAlertDialog(
          title: Text(title),
          content: Text(content),
          actions: <Widget>[
            CupertinoDialogAction(
              child: Text("Ok"),
              isDestructiveAction: false,
              onPressed: () => Navigator.pop(context, true),
            ),
          ],
        );
      },
    );
  }
}
11
likes
40
pub points
44%
popularity

Publisher

verified publisherinfinum.com

Prince of Versions is a plugin which checks for application updates using configuration from some resource (Remote server, Google Play Store or App Store).

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_prince_of_versions