Skip to content

[material_ui] Fix SnackBarThemeData.lerp dropping showCloseIcon - #13449

Merged
auto-submit[bot] merged 3 commits into
flutter:mainfrom
ChandraChaan:material-ui-snackbar-lerp-close-icon
Nov 12, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:mainfrom
ChandraChaan:material-ui-snackbar-lerp-close-icon

Conversation

@ChandraChaan

Copy link
Copy Markdown
Contributor

SnackBarThemeData.lerp never passes showCloseIcon to the constructor, so a lerped theme always has showCloseIcon == null. This shows up during AnimatedTheme transitions, where a snack bar loses the close icon its theme asked for.

This adds showCloseIcon to lerp using the same t < 0.5 switch as the other non-lerpable fields (behavior, dismissDirection), and a unit test covering both halves of the animation and a null theme on either side.

Fixes flutter/flutter#195390

Pre-Review Checklist

@google-cla

google-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Oct 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates SnackBarThemeData.lerp to correctly interpolate the showCloseIcon property, adds a test case to verify this behavior, and includes a pending changelog entry. The review feedback identifies a potential compile-time error in the new test case where a property is accessed directly on the nullable return value of SnackBarThemeData.lerp, suggesting the use of a null-aware operator instead.

Comment on lines +24 to +27
expect(SnackBarThemeData.lerp(a, b, 0.25).showCloseIcon, true);
expect(SnackBarThemeData.lerp(a, b, 0.75).showCloseIcon, false);
expect(SnackBarThemeData.lerp(a, null, 0.25).showCloseIcon, true);
expect(SnackBarThemeData.lerp(null, a, 0.75).showCloseIcon, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Since SnackBarThemeData.lerp returns a nullable SnackBarThemeData?, accessing .showCloseIcon directly without a null-aware operator (?.) or null assertion operator (!) will cause a compile-time analyzer error. Please use ?.showCloseIcon instead.

Suggested change
expect(SnackBarThemeData.lerp(a, b, 0.25).showCloseIcon, true);
expect(SnackBarThemeData.lerp(a, b, 0.75).showCloseIcon, false);
expect(SnackBarThemeData.lerp(a, null, 0.25).showCloseIcon, true);
expect(SnackBarThemeData.lerp(null, a, 0.75).showCloseIcon, true);
expect(SnackBarThemeData.lerp(a, b, 0.25)?.showCloseIcon, true);
expect(SnackBarThemeData.lerp(a, b, 0.75)?.showCloseIcon, false);
expect(SnackBarThemeData.lerp(a, null, 0.25)?.showCloseIcon, true);
expect(SnackBarThemeData.lerp(null, a, 0.75)?.showCloseIcon, true);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

SnackBarThemeData.lerp returns a non-nullable SnackBarThemeData, so .showCloseIcon is fine here. Using ?. gives an invalid_null_aware_operator warning instead, so I've left it as is.

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you for your contribution!

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Added the cicd label

@elliette elliette added the CICD Run CI/CD label Nov 6, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 10, 2026
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews, @QuncCccccc and @elliette!

The two failed presubmit jobs (Linux repo_checks and Windows_x64 repo_tools_tests) were not from this change: the tool unit tests failed to load because MockGitDir was out of date with package:git 2.5.0, which #13544 fixed on main after this branch was cut. I have merged main into the branch so it picks up that fix.

The merge removed the CICD label. Could one of you add it again so the checks can re-run?

@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Gentle follow-up, @QuncCccccc and @elliette: this is approved and up to date with main (synced again just now), and it only needs the CICD label re-added so the presubmits can run. Could one of you add it when you have a moment? Thanks!

@QuncCccccc QuncCccccc added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Nov 12, 2026
@auto-submit
auto-submit Bot merged commit 14f9933 into flutter:main Nov 12, 2026
12 checks passed
b-luk pushed a commit to b-luk/flutter that referenced this pull request Nov 12, 2026
…r#196450)

flutter/packages@653628e...14f9933

2026-11-12 [email protected] [material_ui]
Fix SnackBarThemeData.lerp dropping showCloseIcon
(flutter/packages#13449)
2026-11-11 [email protected] [ci] Update repo
for 3.50 stable release (flutter/packages#13628)
2026-11-11 [email protected] [vector_graphics]
Use font-family lists as a family with fallbacks
(flutter/packages#13552)
2026-11-11 [email protected] Roll Flutter (stable) from
c197ca5 to ab29120 (1647 revisions) (flutter/packages#13625)
2026-11-11 [email protected] [shared_prferences] Adopts
mockito-kotlin in tests (flutter/packages#13624)
2026-11-11 [email protected] [cupertino_ui] Dim disabled
CupertinoSlider controls (flutter/packages#13419)
2026-11-11 [email protected] [flutter_svg] Invalidate pending cache
entries on clear and evict (flutter/packages#13595)
2026-11-11 [email protected] [cupertino_ui] Fix the tinted
button's fill opacity (flutter/packages#13436)
2026-11-11 [email protected] [various]
Support SVG filters (blur, offset, feMerge) (flutter/packages#11909)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material_ui] SnackBarThemeData.lerp drops showCloseIcon

3 participants