[517] Add checkOnResume to stop the version check on app resume - #556
Merged
larryaasen merged 1 commit intoJul 23, 2026
Merged
Conversation
Upgrader retrieved the store version info on every AppLifecycleState.resumed event, which made a network request each time the app returned from the background. This was hardcoded and could not be turned off, and was unrelated to durationUntilAlertAgain, which only controls how often the alert is shown. Added the checkOnResume parameter, defaulting to true, so the existing behavior is unchanged. When false, the version info is only retrieved during initialize(), or when updateVersionInfo() is called directly.
Owner
|
Thanks for this PR. It has been approved and released on pub.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #517.
Problem
Upgraderregisters itself as aWidgetsBindingObserverduringinitialize(), anddidChangeAppLifecycleStateunconditionally calledupdateVersionInfo()on everyAppLifecycleState.resumedevent. That means a network request to the App Store / Play Store every time the app returns from the background, with no way to turn it off.As noted in the issue, this is unrelated to
durationUntilAlertAgain, which only controls how often the alert is displayed, not how often the version info is retrieved. The two are now decoupled.Change
Added a
checkOnResumeparameter toUpgrader, defaulting totrue, so existing behavior is unchanged. Whenfalse, the version info is only retrieved duringinitialize(), or whenupdateVersionInfo()is called directly.The parameter is stored in
UpgraderState, so it can also be changed at runtime:The observer is still registered in both cases; only the version check is skipped, and a debug log line is printed when
debugLoggingis enabled.Tests
Two tests were added using a request counting
MockClient:checkOnResume: false, repeated resume/pause cycles make no additional requests, while the version info frominitialize()remains available andshouldDisplayUpgrade()still returnstrueflutter analyzeis clean and all tests pass.