Repository navigation
fix(navigation): previous page frozen when pushing a MaterialPageRoute - #3490
Open
MikaelDDavidd wants to merge 1 commit into
Open
MikaelDDavidd wants to merge 1 commit into
MikaelDDavidd wants to merge 1 commit into
Conversation
GetPageRouteTransitionMixin.canTransitionTo only returned true for GetPageRoute, Cupertino routes and CupertinoSheetRoute. With a MaterialPageRoute on top (Navigator.push), the previous route's secondaryAnimation stayed at 0, so the page underneath didn't move on push or pop. Accept MaterialRouteTransitionMixin routes too, except fullscreen dialogs. Flutter's MaterialPageRoute.canTransitionTo uses the same check. Fixes jonataslaw#3452
This branch has not been deployed
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 #3452
With GetMaterialApp, pushing a MaterialPageRoute (with Navigator.push, for example) leaves the page underneath frozen. Same thing when you pop it. With a plain MaterialApp both pages animate.
The problem is in
GetPageRouteTransitionMixin.canTransitionTo. It only returns true when the next route is a GetPageRoute, a Cupertino route or a CupertinoSheetRoute. A MaterialPageRoute falls through, so the previous route'ssecondaryAnimationnever leaves 0 and the transitions builder has nothing to animate.I added
MaterialRouteTransitionMixinroutes to that check, skipping fullscreen dialogs. It's the same conditionMaterialPageRoute.canTransitionTouses in Flutter. The GetPageRoute cases didn't change, soGet.to(..., showCupertinoParallax: false)still keeps the previous page still.I ran the code from the issue as a web build, once against master and once against this branch, slowed down with
timeDilation. The screenshot is the same moment of the push usingCupertinoPageTransitionsBuilder, since the 5% scale of the zoom transition is hard to see in a still image. Left is master, right is this branch:The tests are in
test/navigation/outgoing_route_transition_test.dart. Three of them fail on master: thesecondaryAnimationvalue on push, and the position of the previous page on push and on pop. The other three cover things that shouldn't change (fullscreen dialog,Get.to, andGet.towithshowCupertinoParallax: false).All 228 tests pass on Flutter 3.47.8 and 3.50.0.
Pre-launch Checklist
///). No public API changes.