[go: nahoru, domu]

Skip to content
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

Merged
merged 11 commits into from
Sep 3, 2020
Merged

ScaffoldMessenger #64101

merged 11 commits into from
Sep 3, 2020

Conversation

Piinks
Copy link
Contributor
@Piinks Piinks commented Aug 18, 2020

Description

Framework Migration: #64170
Migration Guide: flutter/website#4527

This introduces the ScaffoldMessenger, a new widget for handling SnackBars.
The ScaffoldState methods of [showSnackBar, hideCurrentSnackBar, and removeCurrentSnackBar] will call on the ScaffoldMessenger if used. This prevents users from being broken by the change and allows them time to migrate their code.

By using the ScaffoldMessenger, SnackBars can persist across multiple Scaffolds and transitions. This change also adds a Hero to SnackBars so that they transition smoothly.

Hero flight between Scaffolds:

ezgif com-video-to-gif (8)

Asynchronous SnackBars:

ezgif com-video-to-gif (9)

Follow-up work:

  • There is a SnackBar demo in the cookbook that will need updating
  • Check rest of website for snackbar use
  • Notify customers and deprecate old methods after migration

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.

  • 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 read the Tree Hygiene wiki page, which explains my responsibilities.
  • 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

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.

@Piinks Piinks added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Aug 18, 2020
@flutter-dashboard flutter-dashboard bot added the f: material design flutter/packages/flutter/material repository. label Aug 18, 2020
@flutter-dashboard
Copy link

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.

@flutter-dashboard flutter-dashboard bot added the team Infra upgrades, team productivity, code health, technical debt. See also team: labels. label Aug 19, 2020
@Piinks Piinks mentioned this pull request Aug 19, 2020
13 tasks
@Piinks Piinks removed the f: material design flutter/packages/flutter/material repository. label Aug 19, 2020
@Piinks Piinks added a: quality A truly polished experience c: API break Backwards-incompatible API changes customer: money (g3) labels Aug 26, 2020
@flutter-dashboard flutter-dashboard bot added the f: material design flutter/packages/flutter/material repository. label Aug 26, 2020
@Piinks Piinks changed the title [WIP] ScaffoldMessenger ScaffoldMessenger Aug 26, 2020
@Piinks Piinks removed the f: material design flutter/packages/flutter/material repository. label Aug 26, 2020
@flutter-dashboard flutter-dashboard bot added the f: material design flutter/packages/flutter/material repository. label Aug 27, 2020
Copy link
Contributor
@HansMuller HansMuller left a 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.

packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/scaffold.dart Outdated Show resolved Hide resolved
@Piinks
Copy link
Contributor Author
Piinks commented Aug 31, 2020

I've updated this based on your feedback @HansMuller thank you! PTAL. :)

Copy link
Contributor
@HansMuller HansMuller left a 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);
Copy link
Contributor

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?

@fluttergithubbot fluttergithubbot merged commit 48f1a0a into flutter:master Sep 3, 2020
zanderso added a commit that referenced this pull request Sep 4, 2020
zanderso added a commit that referenced this pull request Sep 4, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@Piinks Piinks mentioned this pull request Sep 23, 2020
9 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: quality A truly polished experience c: API break Backwards-incompatible API changes c: new feature Nothing broken; request for a new capability customer: money (g3) f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show a SnackBar across Scaffolds
4 participants