Skip to content

fix: show UpgradeAlert above subsequent navigator pushes - #541

Open
haashem wants to merge 6 commits into
larryaasen:mainfrom
haashem:main
Open

haashem wants to merge 6 commits into
larryaasen:mainfrom
haashem:main

Conversation

@haashem

@haashem haashem commented Mar 24, 2026

Copy link
Copy Markdown

Resolves #540

Before After
upgrader-before.mov
upgrader-after.mov

@haashem

haashem commented Mar 30, 2026

Copy link
Copy Markdown
Author

@larryaasen could you please review this PR?

}
}
return widget.child ?? const SizedBox.shrink();
return Stack(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haashem This code change impacts all users not just for the use case you are trying to solve. Why is a Stack created (and all of those other widgets) when widget.child is null? Do all existing use cases that already work properly need this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my late reply, Good point. Stack is only needed when UpgraderAlert wraps app content so then it host dialog above subsequent page pushes.
I reverted to original implementation when child is null.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the issue where UpgradeAlert could be obscured by subsequent route pushes (e.g., navigating from a splash screen to home) by ensuring the upgrade dialog is presented above later navigation changes.

Changes:

  • Add an overlay Navigator inside UpgradeAlert so dialogs are shown on a dedicated top-layer navigator (stays above later pushes).
  • Adjust dialog presentation to use the overlay navigator context (useRootNavigator: false).
  • Add a widget test that reproduces a later route push and asserts the alert remains visible.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/src/upgrade_alert.dart Presents the upgrade dialog via a dedicated overlay navigator to keep it above subsequent navigation pushes.
test/upgrade_alert_test.dart Adds a regression test covering route push behavior while the alert is displayed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/upgrade_alert.dart
@larryaasen larryaasen added the need more information Further information is requested label Jun 26, 2026
@larryaasen
larryaasen requested review from larryaasen and a balanced review from Copilot August 21, 2026 11:57
@larryaasen larryaasen added enhancement New feature or request and removed need more information Further information is requested labels Aug 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

lib/src/upgrade_alert.dart:148

  • The private Navigator is not part of WidgetsApp's platform-back dispatch path. Android back is sent to the app navigator, while this dialog's PopScope is registered on a route in _dialogNavigatorKey, so shouldPopScope is no longer invoked and enabled back-button dismissal stops working. The existing regression test at test/upgrader_test.dart:640-659 exercises this path. The nested navigator needs explicit back delegation, or the dialog must remain on a navigator that receives platform pop events.
              child: HeroControllerScope.none(
                child: Navigator(
                  key: _dialogNavigatorKey,

Comment on lines +145 to +147
Positioned.fill(
child: HeroControllerScope.none(
child: Navigator(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haashem Please review this comment.

@haashem haashem Aug 26, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I could reproduce it! Pushed a fix:

UpgradeAlert now uses its private navigator only when wrapping the app above its navigator, such as MaterialApp.builder.
Subtree placements like Scaffold(body: UpgradeAlert(...)) use the root navigator.

Before After
Simulator Screenshot - iPhone 17 Pro - 2026-08-26 at 22 41 48 Simulator Screenshot - iPhone 17 Pro - 2026-08-26 at 22 43 14

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.22%. Comparing base (fc3bf2e) to head (9b3c056).
⚠️ Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #541      +/-   ##
==========================================
- Coverage   92.82%   92.22%   -0.61%     
==========================================
  Files          12       12              
  Lines        1296     1337      +41     
==========================================
+ Hits         1203     1233      +30     
- Misses         93      104      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UpgradeAlert does not remain visible when a new route is pushed:

3 participants