update_required
| Package | Kind | Provides the role | Needs | Choose with |
|---|---|---|---|---|
smf_update_required | feature | none | remote config, store reviews, a router | -m update_required |
update_required is the screen "Update required". While the version of the app is below the lowest version that may run, the screen takes the place of the app, and its button Update opens the page of the app in its store. You set the lowest version in remote config, so you raise it without a new version of the app.
The module keeps no values and opens no store itself. It reads the lowest version from the remote config role, through appRemoteConfig, and opens the store page of the store reviews role, through appReview. So it requires a module that provides each, such as firebase_remote_config and in_app_review, and the screen is the same whichever modules those are. See Remote config.
The screen
| Screen | Route | Path | What it shows |
|---|---|---|---|
UpdateRequiredScreen | update_required.updateRequired | /update_required | That this version of the app is no longer supported, and the button Update, which opens the page of the app in its store. |
From the top, the screen shows:
- the cell of the app, as on the not-found screen of the router, next to the same cell one step higher and filled, with an arrow up in place of its number: the newer version. The symbol and the number come from the name of the app, as on the card of the start screen;
- the title "Update required", and below it "This version of the app is no longer supported. Update the app to keep using it.";
- the button Update, which opens the page of the app in its store, outside the app;
- once the user tapped Update, or at once when no app of the device opened the page, the button Not now. When the page did not open, "Couldn't open the store." shows above it.


The screen has no app bar and no back button: the back button of the system leaves the app.
When it shows
The lowest version that may run is update_required_minimum_version, a text parameter of remote config, which the module gives the remote config role. Its default is empty, which is no lowest version, so the app runs until you set one.
The version of the app is its version name, such as 1.4.0 of version: 1.4.0+12 in pubspec.yaml, without the build number, from package_info_plus. The two compare number by number:
| Rule | Example |
|---|---|
| A version has one to four whole numbers between dots. | 2, 1.4, 1.4.0 and 1.4.0.2 are versions. |
| A missing number is 0. | 1.2 equals 1.2.0. |
| Each number counts as a number, not as text. | 1.10.0 is above 1.9.2. |
A build number after + does not count, nor do spaces around the version. | 1.4.0+12 is 1.4.0. |
| A lowest version that is no version keeps the app running, and a debug build prints why. | 2.0.0-beta |
The comparison is versionBelow() of lib/features/update_required/version_compare.dart, which needs nothing but Dart. A version of the app that is no version, or one that the app cannot read within two seconds, keeps the app running too, and a debug build prints why.
updateStatus of lib/features/update_required/update_status.dart keeps whether the version may run. bootstrap() starts it in its last phase, once the services of the app are ready: it reads the version of the app and follows appRemoteConfig from then on. So the screen takes the place of the app before its first frame, and also while the app runs, once a new lowest version comes. Lower the lowest version or empty it, and the user is back where they were.
The guard
The module declares the guard update_required.supported, whose target is the route of the screen. While the version may not run, the router shows the screen in place of every other screen of the app, whichever module provides the router, and leaves it once the version may run again, for the screen that the guard kept the user from. So nothing navigates to the screen or away from it, and a navigation to /update_required while the version may run shows the screen that the app starts on. See Guards of routes.
The guard has the stage welcome, since it needs to know nothing of the user, so the app asks it before a guard that asks who the user is, such as that of sign_in. Among the guards of that stage, such as that of onboarding, the order of the modules of the app decides which comes first on a launch that needs both: the guard of the module that comes first in the app. With -m home,update_required,onboarding, for example, the screen comes before the onboarding.
The route is no destination of the main navigation, and the app cannot start on it.
Update and Not now
The screen is hard until the user taps Update. From then on, it also offers Not now, which lets the user in for this launch below that lowest version. When no app of the device opened the store page, the screen says so and offers Not now at once. A store page that does not answer within 10 seconds counts as opened.
So a lowest version above the version that the store has, set before the review of a release or during a staged rollout, costs a user one trip to the store and never locks anyone out. The next launch, and another lowest version, show the screen again.
The store page
The button opens the store page of the store reviews role, with appReview.openStorePage(): on Android the page of the app in Google Play, and on iOS its page in the App Store, which needs the App Store ID of the app in REVIEW_APP_STORE_ID of .env. See Store reviews and feedback.
Without the App Store ID, the app has no store page on iOS, and the screen never shows there: a debug build says so, and names the key. Before the app is in Google Play, Update leads to a page that says the item was not found.
When to raise the lowest version
The stores have no forced update of their own: Apple has no API for it, and the app only shows this screen. So:
- Raise the lowest version only when the old versions really cannot work any more, such as after a change of your backend that they do not understand, and only once the new version is in both stores for every user.
- Never raise it above the last version that the oldest system that the app supports can install: a user on that system can update to nothing newer.
- Where the backend of remote config gives a parameter a value for each platform, give each platform its own lowest version when the stores differ.
An app that stays offline never learns a new lowest version, and a user may stay on an old version with Not now. So only the backend of the app can really refuse an old version, such as by the version that each request names.
What it adds to the app
| In the app | What it is |
|---|---|
lib/features/update_required/update_required_screen.dart | UpdateRequiredScreen. |
lib/features/update_required/update_status.dart | updateStatus, which the guard and the screen share, and versionSupported(), the function of the guard. |
lib/features/update_required/version_compare.dart | versionNumbers() and versionBelow(), which compare the versions. |
package_info_plus: ^10.2.0 in the dependencies | The package that reads the version of the app. |
The parameter update_required_minimum_version of remote config | A text, empty by default, read as appRemoteConfig.value.updateRequiredMinimumVersion. |
The route /update_required and the guard update_required.supported | Data of the router role. |
await updateStatus.start(); in the last phase of bootstrap() | The start of updateStatus. |
| The section "Update required" of the README | What takes the place of the app and when, how the versions compare, what Not now is for, the App Store ID on iOS, where the texts are, the order against an onboarding, and when to raise the lowest version. |
The guide for coding agents of the app gets a section "Update required": what shows the screen and when, where its status is, how the versions compare, when Not now shows, and what a test of another screen does about it.
This is bootstrap() of an app with this module and the modules that come with it:
Future<void> bootstrap() async {
checkEnvValues(debugPrint);
await Firebase.initializeApp(options: firebaseOptionsOfFlavor);
await initPreferences();
await initRemoteConfig();
await initReview();
await updateStatus.start();
}
The texts
The module has five texts, in English and in Ukrainian:
| Text | English | Ukrainian |
|---|---|---|
| The title | Update required | Потрібне оновлення |
| The text below it | This version of the app is no longer supported. Update the app to keep using it. | Ця версія застосунку більше не підтримується. Оновіть застосунок, щоб користуватися ним далі. |
| The button | Update | Оновити |
| The second button | Not now | Не зараз |
| When the store did not open | Couldn't open the store. | Не вдалося відкрити магазин. |
The module only uses the localization role. In an app with it, such as with gen_l10n, they are texts of the app, which the screen reads from context.l10n, such as context.l10n.updateRequiredTitle: change them where the provider of the localization keeps the texts of the app, in each language. In an app without it, they are the English texts in the file of the screen. See Languages.
Large text, motion and screen readers
The title is a header for a screen reader that names the screen, and the failure is a live region, which a screen reader reads once it comes. The cell is a picture that a screen reader passes over, and its letters and number keep their size with a larger text. The title and the labels of the buttons grow at most by half, and every text keeps its words whole: it breaks between its words and never inside one. On a small phone with a large text size, the screen scrolls to Not now.
The screen comes in when it shows, and at once in an app that asks for less motion.
In tests
A test of another screen needs nothing: the default of the parameter is empty, so the app runs.
A test of the screen gives appRemoteConfig.start() and appReview.start() services of its own, and updateStatus.start(review: ...) an AppReviewController of its own, such as one with an App Store ID that it scripts. It runs updateStatus.start() again for the next launch. See Remote config.
SMF's CI checks the module in every app with it, as a test of the router role too: the defaults and the lowest versions 1.0.0, 0.9, 1, abc and 1.0.0-beta keep an app of 1.0.0 running, 1.0.1 shows the screen in place of the screen that the app starts on, and lowering it brings the user back. Update opens the store page once, and only then does Not now show. A page that does not open shows the failure and Not now at once. Another lowest version, and the next launch, show the screen again, hard. On iOS it checks the screen without an App Store ID and with one. It also checks that a lowest version that remote config has already takes the place of the app before the first frame, and the screen on a small phone with a large text size, in each language and theme, and with less motion. On a device, it checks that the version that the app read is numbers between dots, and that whether the version may run agrees with remote config and the store page. See Contributing.
Choosing it
smf create asks which features the app has. To choose this one without the question, with a start screen:
smf create my_app -m home,update_required
The module requires the remote config role and the store reviews role, and as a feature it requires a router. smf create adds each when only one module provides it, and with them Firebase, the preferences and the values of .env, which those modules need:
Adding flutter_core: the only provider of the app entry role, which every app needs.
Adding go_router: the only provider of the router role, which home requires.
Adding firebase_remote_config: the only provider of the remote config role, which update_required requires.
Adding firebase_core: a dependency of firebase_remote_config.
Adding in_app_review: the only provider of the store reviews role, which update_required requires.
Adding shared_preferences: the only provider of the preferences role, which in_app_review requires.
Adding dart_define: the only provider of the env role, which in_app_review requires.
The app lists two steps by hand: the App Store ID of the app, review.app_store_id, and the parameters of remote config, firebase_remote_config.parameters. After generation, firebase_core asks whether to configure the flavor dev, as for every app with Firebase; see Firebase.