CheckboxListTile: use Transform.scale only when required (#156593)

Make CheckboxListTile use `Transform.scale` only when required.

Fixes: #81334
This commit is contained in:
Jatin Nagar 2024-10-12 11:07:38 +05:30 committed by GitHub
parent c667c97c3f
commit 63dd042e72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 45 deletions

View File

@ -499,58 +499,58 @@ class CheckboxListTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Widget control;
Widget control;
switch (_checkboxType) {
case _CheckboxType.material:
control = ExcludeFocus(
child: Transform.scale(
scale: checkboxScaleFactor,
child: Checkbox(
value: value,
onChanged: enabled ?? true ? onChanged : null,
mouseCursor: mouseCursor,
activeColor: activeColor,
fillColor: fillColor,
checkColor: checkColor,
hoverColor: hoverColor,
overlayColor: overlayColor,
splashRadius: splashRadius,
materialTapTargetSize: materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus,
tristate: tristate,
shape: checkboxShape,
side: side,
isError: isError,
semanticLabel: checkboxSemanticLabel,
),
child: Checkbox(
value: value,
onChanged: enabled ?? true ? onChanged : null,
mouseCursor: mouseCursor,
activeColor: activeColor,
fillColor: fillColor,
checkColor: checkColor,
hoverColor: hoverColor,
overlayColor: overlayColor,
splashRadius: splashRadius,
materialTapTargetSize: materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus,
tristate: tristate,
shape: checkboxShape,
side: side,
isError: isError,
semanticLabel: checkboxSemanticLabel,
),
);
case _CheckboxType.adaptive:
control = ExcludeFocus(
child: Transform.scale(
scale: checkboxScaleFactor,
child: Checkbox.adaptive(
value: value,
onChanged: enabled ?? true ? onChanged : null,
mouseCursor: mouseCursor,
activeColor: activeColor,
fillColor: fillColor,
checkColor: checkColor,
hoverColor: hoverColor,
overlayColor: overlayColor,
splashRadius: splashRadius,
materialTapTargetSize: materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus,
tristate: tristate,
shape: checkboxShape,
side: side,
isError: isError,
semanticLabel: checkboxSemanticLabel,
),
child: Checkbox.adaptive(
value: value,
onChanged: enabled ?? true ? onChanged : null,
mouseCursor: mouseCursor,
activeColor: activeColor,
fillColor: fillColor,
checkColor: checkColor,
hoverColor: hoverColor,
overlayColor: overlayColor,
splashRadius: splashRadius,
materialTapTargetSize: materialTapTargetSize ?? MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus,
tristate: tristate,
shape: checkboxShape,
side: side,
isError: isError,
semanticLabel: checkboxSemanticLabel,
),
);
}
if (checkboxScaleFactor != 1.0) {
control = Transform.scale(
scale: checkboxScaleFactor,
child: control,
);
}
final ListTileThemeData listTileTheme = ListTileTheme.of(context);
final ListTileControlAffinity effectiveControlAffinity =

View File

@ -1277,14 +1277,12 @@ void main() {
),
));
final Transform widget = tester.widget(
find.ancestor(
final Finder transformFinder = find.ancestor(
of: find.byType(Checkbox),
matching: find.byType(Transform),
),
);
expect(widget.transform.getMaxScaleOnAxis(), 1.0);
expect(transformFinder, findsNothing);
});
testWidgets('CheckboxListTile respects checkboxScaleFactor', (WidgetTester tester) async {