Skip to content

[material_ui] Include layoutBehavior in ButtonThemeData equality - #13517

Open
ChandraChaan wants to merge 3 commits into
flutter:mainfrom
ChandraChaan:button-theme-layout-behavior-equality
Open

ChandraChaan wants to merge 3 commits 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

ButtonThemeData's ==, hashCode and debugFillProperties skipped
layoutBehavior, so two themes that differ only in layoutBehavior
compared equal and ButtonTheme did not notify its dependents.
@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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] ButtonThemeData == and hashCode ignore layoutBehavior

1 participant