Skip to content

Commit

Permalink
Reland: Added ButtonStyle.foregroundBuilder and ButtonStyle.backgroun…
Browse files Browse the repository at this point in the history
…dBuilder (#142762)

Reland flutter/flutter#141818 with a fix for a special case: If only `background` is specified for `TextButton.styleFrom` or `OutlinedButton.styleFrom` it applies the button's disabled state, i.e. as if the same value had been specified for disabledBackgroundColor.

The change relative to #141818 is the indicated line below:
```dart
final MaterialStateProperty<Color?>? backgroundColorProp = switch ((backgroundColor, disabledBackgroundColor)) {
  (null, null) => null,
  (_, null) => MaterialStatePropertyAll<Color?>(backgroundColor), // ADDED THIS LINE
  (_, _) => _TextButtonDefaultColor(backgroundColor, disabledBackgroundColor),
};
  ```

This backwards incompatibility cropped up in an internal test, see internal Google issue b/323399158.
  • Loading branch information
HansMuller authored Feb 2, 2024
1 parent c13ebf1 commit c6f2cea
Show file tree
Hide file tree
Showing 15 changed files with 1,618 additions and 188 deletions.
1 change: 0 additions & 1 deletion dev/bots/check_code_samples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ final Set<String> _knownMissingTests = <String>{
'examples/api/test/material/checkbox/checkbox.1_test.dart',
'examples/api/test/material/checkbox/checkbox.0_test.dart',
'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart',
'examples/api/test/material/text_button/text_button.0_test.dart',
'examples/api/test/rendering/growth_direction/growth_direction.0_test.dart',
'examples/api/test/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0_test.dart',
'examples/api/test/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.1_test.dart',
Expand Down
Loading

0 comments on commit c6f2cea

Please sign in to comment.