ScaffoldMessenger only shows to root nested Scaffold#74093
Conversation
|
Gold has detected about 2 untriaged digest(s) on patchset 1. |
|
Gold has detected about 1 untriaged digest(s) on patchset 2. |
|
Just update your branch can fix the CI checks :) |
|
Gold has detected about 2 untriaged digest(s) on patchset 4. |
|
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| for (final ScaffoldState scaffold in _scaffolds) { | ||
| scaffold._updateSnackBar(); | ||
| if (_isRoot(scaffold)) | ||
| scaffold._updateSnackBar(); |
There was a problem hiding this comment.
At this point it would be safe to return.
There was a problem hiding this comment.
Not necessarily. There can be other Scaffolds that need to get a SnackBar. For example, on another route. That is how we get the nice hero animation as the SnackBar persists across the transition.
There was a problem hiding this comment.
I see. Hopefully there's a test that will catch someone (like me) adding the short-circuit return without realizing the implications
| ), | ||
| )); | ||
|
|
||
| final ScaffoldMessengerState scaffoldMessengerState = tester.state( |
There was a problem hiding this comment.
With the type parameter: tester.state<ScaffoldMessengerState>(
It's a shame that the same identifier has to be repeated 3x :-(
There was a problem hiding this comment.
What is being repeated 3x?
There was a problem hiding this comment.
final ScaffoldMessengerState scaffoldMessengerState = tester.state<ScaffoldMessengerState>(
| /// ScaffoldMessenger will only present a [SnackBar] to the root Scaffold of | ||
| /// the subtree of Scaffolds. In order to show SnackBars in the inner, nested | ||
| /// Scaffolds, set a new scope for your SnackBars by instantiating a new | ||
| /// ScaffoldMessenger in between the levels of nesting. |
There was a problem hiding this comment.
optional: may be nice to show a code sample of that here.
There was a problem hiding this comment.
What do you think of linking to an example in the gallery? I think this sample would be very large to include inline, and I don't want to encourage nesting scaffolds... there is a section in the Scaffold docs that says nested Scaffolds is not typically necessary. There are a few cases where it is relevant - like in the gallery where there is embedded Flutter content, but the Scaffold docs recommend avoiding nesting.
|
Gold has detected about 1 untriaged digest(s) on patchset 5. |
|
Golden file changes are available for triage from new commit, Click here to view. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
This change makes it such that when a ScaffoldMessenger has nested Scaffold descendants, it will only show SnackBars on the root Scaffold of the subtree. This will remove the possibility of duplicate SnackBars showing up in the UI in this use case.
This change is courtesy of early customer feedback. :)
See b/171649782
Fixes #69929
Other options discussed were to
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.