Skip to content

[material_ui] Include layoutBehavior in ButtonThemeData equality - #13517

Merged
auto-submit[bot] merged 1 commit into
flutter:mainfrom
ChandraChaan:button-theme-layout-behavior-equality
Nov 18, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:mainfrom
ChandraChaan:button-theme-layout-behavior-equality

Conversation

@ChandraChaan

Copy link
Copy Markdown
Contributor

ButtonThemeData's ==, hashCode and debugFillProperties skip layoutBehavior, so ButtonThemeData() and ButtonThemeData(layoutBehavior: ButtonBarLayoutBehavior.constrained) compare equal. Since ButtonTheme.updateShouldNotify compares data, changing only layoutBehavior doesn't notify dependents either.

This adds layoutBehavior to all three, with tests for equality, hashCode and the diagnostics output (both fail without the change).

Fixes flutter/flutter#195754

Pre-Review Checklist

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Nov 1, 2026
@ChandraChaan
ChandraChaan marked this pull request as ready for review November 12, 2026 03:35
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Hi @QuncCccccc and @elliette, thanks again for reviewing and landing #13449! This one is out of draft now and is the same kind of fix in material_ui: ButtonThemeData leaves layoutBehavior out of ==, hashCode and debugFillProperties, so changing only layoutBehavior does not notify dependents. Tests cover all three.

Would one of you be able to take a look when you have time? It will also need the CICD label for the presubmits. Thanks!

@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 ButtonThemeData to include layoutBehavior in its equality operator, hashCode, and diagnostics properties, and adds corresponding unit tests. The feedback suggests removing a redundant import of package:flutter/rendering.dart in the test file, as the required diagnostics classes are already exported by package:flutter_test/flutter_test.dart.

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/rendering.dart';

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.

medium

The import of package:flutter/rendering.dart is redundant because all necessary diagnostics classes (such as DiagnosticPropertiesBuilder, DiagnosticsNode, and DiagnosticLevel) are already transitively exported by package:flutter_test/flutter_test.dart. Removing this unused import keeps the codebase clean and avoids unnecessary dependencies.

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.

This import is needed: flutter_test does not re-export package:flutter/foundation.dart, and material_ui (via widgets.dart) only re-exports Brightness and UniqueKey from it. Without package:flutter/rendering.dart, DiagnosticPropertiesBuilder, DiagnosticsNode and DiagnosticLevel are undefined. The other *_theme_test.dart files in this package import it for the same reason, so I have left it as is.

@github-actions github-actions Bot added the P3 Issues that are less important to the Flutter project label Nov 16, 2026
@Piinks
Piinks requested a review from QuncCccccc November 17, 2026 22:14

@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, thanks!

Just for the record: ButtonTheme/ButtonThemeData should have been deprecated, since no Material 3 widget uses it (the M3 buttons have their own themes, like ElevatedButtonTheme). See flutter/flutter#77569. This fix is still worth landing since it's small and correct.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Nov 18, 2026
@QuncCccccc
QuncCccccc requested a review from elliette November 18, 2026 00:35
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for adding the label, @QuncCccccc! And thanks for the context on ButtonThemeData and flutter/flutter#77569, good to know.

@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit

auto-submit Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/13517, because - The status or check suite scan-pr has failed. Please fix the issues identified (or deflake) before re-applying this label.

ButtonThemeData's ==, hashCode and debugFillProperties skipped
layoutBehavior, so two themes that differ only in layoutBehavior
compared equal and ButtonTheme did not notify its dependents.
@QuncCccccc
QuncCccccc force-pushed the button-theme-layout-behavior-equality branch from 8bde1e1 to 6899374 Compare November 18, 2026 19:09
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 18, 2026
@QuncCccccc QuncCccccc added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Nov 18, 2026
@auto-submit
auto-submit Bot merged commit 0b35215 into flutter:main Nov 18, 2026
12 checks passed
BeatusMomentum pushed a commit to BeatusMomentum/flutter that referenced this pull request Nov 19, 2026
…r#196992)

flutter/packages@dca2e58...81b7c44

2026-11-19 36861262+QuncCccccc@users.noreply.github.com [material_ui]
Generalize ButtonTemplateM3E to read the tokens of each button variant
(flutter/packages#13684)
2026-11-19 engine-flutter-autoroll@skia.org Roll Flutter from
06f32f8 to e8cc6f3 (30 revisions) (flutter/packages#13719)
2026-11-18 katelovett@google.com [ci] Fix workflow permissions
(flutter/packages#13713)
2026-11-18 engine-flutter-autoroll@skia.org Roll Flutter from
2f09f96 to 06f32f8 (18 revisions) (flutter/packages#13712)
2026-11-18 53801679+ChandraChaan@users.noreply.github.com [material_ui]
Include layoutBehavior in ButtonThemeData equality
(flutter/packages#13517)
2026-11-18 21270878+elliette@users.noreply.github.com [tool] Set up the
`script/ci_info` package and add initial `find_builds` tool
(flutter/packages#13580)

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 flutter-ecosystem@google.com 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 P3 Issues that are less important to the Flutter project triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material_ui] ButtonThemeData == and hashCode ignore layoutBehavior

3 participants