这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Merged
merged 4 commits into from
Oct 31, 2019

Conversation

goderbauer
Copy link
Member

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:

  • OverlayEntry.opaque can be changed when OverlayEntry is not part of an Overlay (yet)
  • OverlayEntry of topmost initial route is marked as opaque
  • OverlayEntry of topmost route is set to opaque after Push
  • OverlayEntry of topmost route is set to opaque after Replace

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Oct 29, 2019
@goderbauer goderbauer marked this pull request as ready for review October 29, 2019 21:35
@fluttergithubbot fluttergithubbot added the f: material design flutter/packages/flutter/material repository. label Oct 29, 2019
@goderbauer goderbauer removed f: material design flutter/packages/flutter/material repository. work in progress; do not review labels Oct 29, 2019
@goderbauer
Copy link
Member Author

goderbauer commented Oct 29, 2019

@@ -1754,7 +1754,7 @@ Future<void> main() async {
routes: routes,
initialRoute: '/two',
));
expect(find.text('two'), findsOneWidget);
expect(tester.takeException(), isNull);
Copy link
Contributor

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?

Copy link
Member Author

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.

@Piinks Piinks added a: animation Animation APIs f: inspector Part of widget inspector in framework. f: routes Navigator, Router, and related APIs. labels Oct 29, 2019
Copy link
Contributor

@chunhtai chunhtai left a 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:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, ending with dot

@goderbauer goderbauer merged commit 07a09c4 into flutter:master Oct 31, 2019
@goderbauer goderbauer deleted the fixRouteOpaqueness branch October 31, 2019 18:32
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Nov 26, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: animation Animation APIs f: inspector Part of widget inspector in framework. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tooling] MaterialApp Navigator stack appears as children in the widget tree
6 participants