-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Mark routes as opaque when added without animation #43756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1754,7 +1754,7 @@ Future<void> main() async { | |||
routes: routes, | |||
initialRoute: '/two', | |||
)); | |||
expect(find.text('two'), findsOneWidget); | |||
expect(tester.takeException(), isNull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. This was the actual intent of the test at the time - I probably either mistook which route actually had which widget, or was just doing this to make sure we didn't fire an assert.
Would it be worth testing here expect(find.text('two'), findsNothing)
and expect(find.text('three'), findsOneWidget)
?
Also, should we be worried about this breaking internal tests that relied on this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added those expects.
I think we just have to update those tests then. They are relying on a bug. Doing so is easy, see some of the other tests in this PR that I had to update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with some nit
newEntry.opaque = true; // Does neither trigger an assert nor throw. | ||
expect(newEntry.opaque, isTrue); | ||
|
||
// The new opaqueness is honored when inserted into an overlay: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, ending with dot
Description
Prior to this change TransitionRoutes that were added without animation would not properly mark their first OverlayEntry as opaque. This means Flutter was rendering Routes that weren't visible (and those invisible Routes also showed up in the inspector and confused people there). This happened most prominently when the initial routes where added because those always skip their entrance animation.
This change now properly marks the OverlayEntrys of those routes as opaque.
It also modifies OverlayEntry.opaque to allow modifying the opaqueness before the entry is added to an overlay.
Related Issues
Fixes #38038.
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?