neoversion 0.0.2 copy "neoversion: ^0.0.2" to clipboard
neoversion: ^0.0.2 copied to clipboard

Check if an app has a newer version on the app stores, and prompt the user to update if needed.

example/lib/main.dart

// ignore_for_file: dead_code

// credits: https://github.com/timtraversy/new_version/blob/master/example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();

    final neoVersion = NeoVersion(
      androidAppId: 'app.somus.social',
      iOSAppId: 'app.somus.social',
    );

    const simpleBehavior = true;

    if (simpleBehavior) {
      basicStatusCheck(neoVersion);
    } else {
      advancedStatusCheck(neoVersion);
    }
  }

  basicStatusCheck(NeoVersion neoVersion) {
    neoVersion.showAlertIfNecessary(context: context);
  }

  advancedStatusCheck(NeoVersion neoVersion) async {
    final status = await neoVersion.getVersionStatus();
    debugPrint(status.appStoreUrl);
    debugPrint(status.localVersion);
    debugPrint(status.appStoreVersion);
    debugPrint(status.needsUpdate.toString());
    neoVersion.showUpdateDialog(
      context: context,
      status: status,
      title: 'Custom Title',
      dialogText: (String local, String appstore, bool dismissable) =>
          'Custom Text - local: $local, appstore: $appstore, dismissable: $dismissable',
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Example App for NeoVersion"),
      ),
    );
  }
}
4
likes
140
points
61
downloads

Publisher

verified publishersallai.me

Weekly Downloads

Check if an app has a newer version on the app stores, and prompt the user to update if needed.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, package_info_plus, peekanapp, url_launcher

More

Packages that depend on neoversion