import 'package:flutter/material.dart'; import 'package:native_updater/native_updater.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'native_updater example', home: Home(), ); } } class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State { @override void initState() { super.initState(); checkVersion(); } Future checkVersion() async { /// For example: You got status code of 412 from the /// response of HTTP request. /// Let's say the statusCode 412 requires you to force update int statusCode = 412; /// This could be kept in our local int localVersion = 9; /// This could get from the API int serverLatestVersion = 10; Future.delayed(Duration.zero, () { if (statusCode == 412) { NativeUpdater.displayUpdateAlert( context, forceUpdate: true, appStoreUrl: '', iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSCloseButtonLabel: 'Exit', ); } else if (serverLatestVersion > localVersion) { NativeUpdater.displayUpdateAlert( context, forceUpdate: false, appStoreUrl: '', iOSDescription: '', iOSUpdateButtonLabel: 'Upgrade', iOSIgnoreButtonLabel: 'Next Time', ); } }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Your App'), ), body: Center( child: Text('Testing...'), ), ); } }