flutter/packages
Qun Cheng 7ff5f81a2e
Fix SegmentedButton default size and default tappable size (#142243)
fix https://github.com/flutter/flutter/issues/121493

`SegmentedButton` uses `TextButton` for each segments. When we have `MaterialTapTargetSize.padded` for `TextButton`, we make sure the minimum tap target size is 48.0( this value can be adjusted by visual density), even tough the actual button size is smaller. When `SegmentedButton` paints segments by using `MultiChildRenderObjectWidget`, it also includes the tap target size so the button that it actually draws always has the same height as the height of the tap target size.

To fix it, this PR firstly calculate the actual height of a text button in `SegmentedButton` class, then we can get the height delta if there is. Then the the value of (Segmented button render box height - the delta) would be the actual button size that we should see.

For now, we are not able to customize the min, max, fixed size in [`SegmentedButton` style](https://api.flutter.dev/flutter/material/SegmentedButton/style.html). So the standard button height is always 40 and can only be customized by `style.visualDensity` and `style.tapTargetSize`; `SegmentedButton` only simulates the `TextButton` behavior when `TextButton`'s height is its default value.

![Screenshot 2024-01-25 at 11 45 42 AM](https://github.com/flutter/flutter/assets/36861262/7451fa96-6d45-4cd3-a894-ca71e776c8ef)

https://github.com/flutter/flutter/assets/36861262/15ca6034-e6e0-4cc6-8fe3-808b4bd6a920
2024-01-26 00:20:21 +00:00
..
flutter Fix SegmentedButton default size and default tappable size (#142243) 2024-01-26 00:20:21 +00:00
flutter_driver Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
flutter_goldens Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
flutter_localizations Fix incorrect zh-cn translation for Look Up Label in selection controls (#142158) 2024-01-25 10:24:42 -08:00
flutter_test Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
flutter_tools Enable native compilation for windows-arm64 (#141930) 2024-01-26 00:08:20 +00:00
flutter_web_plugins Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
fuchsia_remote_debug_protocol Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
integration_test Upgrade leak_tracker. (#142162) 2024-01-24 15:33:17 -08:00
analysis_options.yaml Unify analysis options (#108462) 2022-07-28 09:07:49 -07:00