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
ScaffoldMessenger #64101
ScaffoldMessenger #64101
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
9797273
to
d608e4a
Compare
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 looks good, most of the feedback is just small stuff.
I've updated this based on your feedback @HansMuller thank you! PTAL. :) |
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
} | ||
|
||
void _unregister(ScaffoldState scaffold) { | ||
_scaffolds.remove(scaffold); |
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.
Should we assert(_scaffolds.remove(scaffold))
here?
This reverts commit 48f1a0a.
Description
Framework Migration: #64170
Migration Guide: flutter/website#4527
This introduces the
ScaffoldMessenger
, a new widget for handlingSnackBar
s.The
ScaffoldState
methods of [showSnackBar
,hideCurrentSnackBar
, andremoveCurrentSnackBar
] will call on theScaffoldMessenger
if used. This prevents users from being broken by the change and allows them time to migrate their code.By using the
ScaffoldMessenger
,SnackBar
s can persist across multipleScaffold
s and transitions. This change also adds aHero
toSnackBar
s so that they transition smoothly.Hero flight between Scaffolds:
Asynchronous SnackBars:
Follow-up work:
Related Issues
Fixes #62921
Tests
All existing
SnackBar
tests have been migrated and passed. Added a few more for new persistence across routes.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
Did any tests fail when you ran them? Please read Handling breaking changes.
Kind of, all calls to `Scaffold.of(context).showSnackBar/removeCurrentSnackBar/hideCurrentSnackBar are deprecated, but still work since they now call on the ScaffoldMessenger. This should not explicitly break anyone. Treating it as breaking anyways.