app_update_alert 1.5.5 app_update_alert: ^1.5.5 copied to clipboard
Allow users keep your app up to date on their devices, they can try new features, as well as benefit from performance improvements and bug fixes.
import 'package:app_update_alert/appApdateAlert.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
MyHomePageState createState() => MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> {
@override
void initState() {
super.initState();
// Instantiate AppUpdate manager object (Using GCP Console app as example)
final appUpdate = AppUpdates(
iosPackageName: 'com.google.Vespa',
androidPackageName: 'com.google.android.apps.cloudconsole',
iosAppStoreCountry: 'in'
);
// Instantiate AppUpdate manager object with forceAppVersion
final forceAppUpdate = AppUpdates(
iosAppStoreCountry: 'in',
forceAppVersion: '1.0.1'
);
// You can let the plugin handle fetching the status and showing a dialog,
// or you can add version and forceUpdate the status to display the dialog.
const forceUpdate = true;
if (forceUpdate) {
showUpdateDialog(forceAppUpdate);
} else {
showUpdateDialog(appUpdate);
}
}
showUpdateDialog(AppUpdates appUpdate) {
appUpdate.showUpdateAlert(context: context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Example App"),
),
);
}
}