Repository navigation
[material_ui] Include layoutBehavior in ButtonThemeData equality - #13517
ChandraChaan wants to merge 3 commits into
Conversation
ButtonThemeData's ==, hashCode and debugFillProperties skipped layoutBehavior, so two themes that differ only in layoutBehavior compared equal and ButtonTheme did not notify its dependents.
|
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 Would one of you be able to take a look when you have time? It will also need the |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ButtonThemeData's==,hashCodeanddebugFillPropertiesskiplayoutBehavior, soButtonThemeData()andButtonThemeData(layoutBehavior: ButtonBarLayoutBehavior.constrained)compare equal. SinceButtonTheme.updateShouldNotifycomparesdata, changing onlylayoutBehaviordoesn't notify dependents either.This adds
layoutBehaviorto all three, with tests for equality,hashCodeand the diagnostics output (both fail without the change).Fixes flutter/flutter#195754
Pre-Review Checklist
[shared_preferences]///).