Unverified Commit 35174124 authored by Ayush Bherwani's avatar Ayush Bherwani Committed by GitHub

Exposes ListTile.shape for CheckboxListTile and SwitchListTile (#67419)

parent b3f9944f
......@@ -272,6 +272,7 @@ class CheckboxListTile extends StatelessWidget {
this.autofocus = false,
this.contentPadding,
this.tristate = false,
this.shape,
}) : assert(tristate != null),
assert(tristate || value != null),
assert(isThreeLine != null),
......@@ -380,6 +381,9 @@ class CheckboxListTile extends StatelessWidget {
/// If tristate is false (the default), [value] must not be null.
final bool tristate;
/// {@macro flutter.material.ListTile.shape}
final ShapeBorder? shape;
void _handleValueChange() {
assert(onChanged != null);
switch (value) {
......@@ -433,6 +437,7 @@ class CheckboxListTile extends StatelessWidget {
selected: selected,
autofocus: autofocus,
contentPadding: contentPadding,
shape: shape,
),
),
);
......
......@@ -96,7 +96,9 @@ class ListTileTheme extends InheritedTheme {
/// If true then [ListTile]s will have the vertically dense layout.
final bool dense;
/// {@template flutter.material.ListTile.shape}
/// If specified, [shape] defines the shape of the [ListTile]'s [InkWell] border.
/// {@endtemplate}
final ShapeBorder? shape;
/// If specified, [style] defines the font used for [ListTile] titles.
......
......@@ -273,6 +273,7 @@ class SwitchListTile extends StatelessWidget {
this.selected = false,
this.autofocus = false,
this.controlAffinity = ListTileControlAffinity.platform,
this.shape,
}) : _switchListTileType = _SwitchListTileType.material,
assert(value != null),
assert(isThreeLine != null),
......@@ -308,6 +309,7 @@ class SwitchListTile extends StatelessWidget {
this.selected = false,
this.autofocus = false,
this.controlAffinity = ListTileControlAffinity.platform,
this.shape,
}) : _switchListTileType = _SwitchListTileType.adaptive,
assert(value != null),
assert(isThreeLine != null),
......@@ -435,6 +437,9 @@ class SwitchListTile extends StatelessWidget {
/// By default, the value of `controlAffinity` is [ListTileControlAffinity.platform].
final ListTileControlAffinity controlAffinity;
/// {@macro flutter.material.ListTile.shape}
final ShapeBorder? shape;
@override
Widget build(BuildContext context) {
Widget control;
......@@ -497,6 +502,7 @@ class SwitchListTile extends StatelessWidget {
onTap: onChanged != null ? () { onChanged!(!value); } : null,
selected: selected,
autofocus: autofocus,
shape: shape,
),
),
);
......
......@@ -224,4 +224,21 @@ void main() {
await tester.pumpAndSettle();
expect(_value, false);
});
testWidgets('CheckboxListTile respects shape', (WidgetTester tester) async {
const ShapeBorder shapeBorder = RoundedRectangleBorder(
borderRadius: BorderRadius.horizontal(right: Radius.circular(100))
);
await tester.pumpWidget(wrap(
child: const CheckboxListTile(
value: false,
onChanged: null,
title: Text('Title'),
shape: shapeBorder,
),
));
expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder);
});
}
......@@ -340,4 +340,23 @@ void main() {
expect(listTile.leading.runtimeType, Icon);
expect(listTile.trailing.runtimeType, Switch);
});
testWidgets('SwitchListTile respects shape', (WidgetTester tester) async {
const ShapeBorder shapeBorder = RoundedRectangleBorder(
borderRadius: BorderRadius.horizontal(right: Radius.circular(100))
);
await tester.pumpWidget(const MaterialApp(
home: Material(
child: SwitchListTile(
value: true,
onChanged: null,
title: Text('Title'),
shape: shapeBorder,
),
),
));
expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment