mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
CheckboxListTile: use Transform.scale only when required (#156593)
Make CheckboxListTile use `Transform.scale` only when required. Fixes: #81334
This commit is contained in:
parent
c667c97c3f
commit
63dd042e72
@ -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 =
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user