flutter_upgrade_version 1.0.4 copy "flutter_upgrade_version: ^1.0.4" to clipboard
flutter_upgrade_version: ^1.0.4 copied to clipboard

Support to get Package Information(app name, package name, version, build number), get information of version on store (CH Play and Apple Store).

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter_upgrade_version/flutter_upgrade_version.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  PackageInfo _packageInfo = PackageInfo();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> getPackageData() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    _packageInfo = await PackageManager.getPackageInfo();
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    // UpgradeVersion.getUpgradeVersionInfo().then((value) {
    //   print(value?.toJson());
    // });
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SizedBox(
          width: double.infinity,
          child: SingleChildScrollView(
            physics: const ClampingScrollPhysics(),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                const SizedBox(height: 20),
                Text(
                  'Version: ${_packageInfo.version}',
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 20),
                ElevatedButton(
                  onPressed: () {
                    // getPackageData();
                    // UpgradeVersion.getUpgradeVersionInfo().then((value) {
                    //   print(value?.toJson());
                    // });

                    InAppUpdateManager _manager = InAppUpdateManager();
                    _manager.checkForUpdate().then((value) {
                      debugPrint("check for update done");
                      debugPrint('$value');
                    });
                  },
                  child: const Text('Refresh'),
                ),
                const SizedBox(height: 20),
              ],
            ),
          ),
        )
      ),
    );
  }
}
59
likes
0
points
1.9k
downloads

Publisher

unverified uploader

Weekly Downloads

Support to get Package Information(app name, package name, version, build number), get information of version on store (CH Play and Apple Store).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, html, http

More

Packages that depend on flutter_upgrade_version