Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve README example code - fix examples, remove outdated params, f…
…ix documentation errors

Co-authored-by: larryaasen <325973+larryaasen@users.noreply.github.com>
  • Loading branch information
Copilot and larryaasen committed Feb 20, 2026
commit 975c25fc9bde3d49ce72380d7b844280730386b9
75 changes: 47 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ Tapping the UPDATE NOW button takes the user to the App Store (iOS) or Google Pl
Just wrap your home widget in the `UpgradeAlert` widget, and it will handle the rest. Make sure `UpgradeAlert`
is below `MaterialApp` in the widget tree.
```dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

Expand All @@ -60,10 +65,11 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: 'Upgrader Example',
home: UpgradeAlert(
child: Scaffold(
appBar: AppBar(title: Text('Upgrader Example')),
body: Center(child: Text('Checking...')),
)),
child: Scaffold(
appBar: AppBar(title: const Text('Upgrader Example')),
body: const Center(child: Text('Checking...')),
),
),
);
}
}
Expand Down Expand Up @@ -162,28 +168,28 @@ The `Upgrader` class can be customized by setting parameters in the constructor,
* messages: optional localized messages used for display in `upgrader`
* minAppVersion: the minimum app version supported by this app. Earlier versions of this app will be forced to update to the current version. It should be a valid version string like this: ```2.0.13```. Overrides any minimum app version from UpgraderStore. Defaults to ```null```.
* storeController: a controller that provides the store details for each platform, defaults to `UpgraderStoreController()`.
* upgraderDevice: an abstraction of the device_info details which is used for the OS version, defaults to `UpgraderDevice()`.
* upgraderOS: information on which OS this code is running on, defaults to `UpgraderOS()`.
* willDisplayUpgrade: called when ```upgrader``` determines that an upgrade may
or may not be displayed, defaults to ```null```

The `UpgraderStoreController` class is a controller that provides the store details
for each platform.
* onAndroid: defaults to `UpgraderPlayStore()` that extends `UpgraderStore`.
* onFuchsia: defaults to `UpgraderAppStore()` that extends `UpgraderStore`.
* oniOS: defaults to `null`.
* onFuchsia: defaults to `null`.
* oniOS: defaults to `UpgraderAppStore()` that extends `UpgraderStore`.
* onLinux: defaults to `null`.
* onMacOS: defaults to `null`.
* onWeb: defaults to `null`.
* onWindows: defaults to `null`.

To change the `UpgraderStore` for a platform, replace the platform with a
different store. Here is an example of using an Appcast on iOS.
```
```dart
const appcastURL = 'https://raw.githubusercontent.com/larryaasen/upgrader/main/test/testappcast.xml';
final upgrader = Upgrader(
storeController: UpgraderStoreController(
onAndroid: () => UpgraderPlayStore(),
oniOS: () => UpgraderAppcastStore(appcastURL: appcastURL, osVersion: osVersion),
oniOS: () => UpgraderAppcastStore(appcastURL: appcastURL, osVersion: Version(0, 0, 0)),
),
);
```
Expand Down Expand Up @@ -243,7 +249,7 @@ check out the [example/lib/main_gorouter.dart](example/lib/main_gorouter.dart) e
builder: (context, child) {
return UpgradeAlert(
navigatorKey: routerConfig.routerDelegate.navigatorKey,
child: child ?? Text('child'),
child: child ?? const Text('child'),
);
},
);
Expand Down Expand Up @@ -280,7 +286,7 @@ Example:
When using the ```UpgradeAlert``` widget, the Android back button will not
dismiss the alert dialog by default. To allow the back button to dismiss the
dialog, use ```shouldPopScope``` and return true like this:
```
```dart
UpgradeAlert(shouldPopScope: () => true);
```

Expand Down Expand Up @@ -335,25 +341,38 @@ Flutter package, is used by `upgrader` to download app details from an appcast.
### Appcast Example
This is an Appcast example for Android.
```dart
static const appcastURL =
'https://raw.githubusercontent.com/larryaasen/upgrader/main/test/testappcast.xml';
final upgrader = Upgrader(
storeController: UpgraderStoreController(
onAndroid: () => UpgraderAppcastStore(appcastURL: appcastURL, osVersion: osVersion),
),
);
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

static const appcastURL =
'https://raw.githubusercontent.com/larryaasen/upgrader/main/test/testappcast.xml';

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Upgrader Example',
home: Scaffold(
appBar: AppBar(title: Text('Upgrader Appcast Example')),
body: UpgradeAlert(
upgrader: upgrader,
child: Center(child: Text('Checking...')),
)),
// Pass the actual OS version for accurate Appcast item filtering.
// See example/lib/main_appcast.dart for how to retrieve the OS version
// using the device_info_plus package.
static final upgrader = Upgrader(
storeController: UpgraderStoreController(
onAndroid: () => UpgraderAppcastStore(appcastURL: appcastURL, osVersion: Version(0, 0, 0)),
),
);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Upgrader Example',
home: Scaffold(
appBar: AppBar(title: const Text('Upgrader Appcast Example')),
body: UpgradeAlert(
upgrader: upgrader,
child: const Center(child: Text('Checking...')),
)),
);
}
}
```

Expand Down