Unverified Commit 0978b96e authored by Viren Khatri's avatar Viren Khatri Committed by GitHub

Adds `CheckboxListTile.checkboxShape` (#95714)

parent fd6547e1
...@@ -137,6 +137,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -137,6 +137,7 @@ class CheckboxListTile extends StatelessWidget {
this.contentPadding, this.contentPadding,
this.tristate = false, this.tristate = false,
this.shape, this.shape,
this.checkboxShape,
this.selectedTileColor, this.selectedTileColor,
this.side, this.side,
this.visualDensity, this.visualDensity,
...@@ -256,6 +257,13 @@ class CheckboxListTile extends StatelessWidget { ...@@ -256,6 +257,13 @@ class CheckboxListTile extends StatelessWidget {
/// {@macro flutter.material.ListTile.shape} /// {@macro flutter.material.ListTile.shape}
final ShapeBorder? shape; final ShapeBorder? shape;
/// {@macro flutter.material.checkbox.shape}
///
/// If this property is null then [CheckboxThemeData.shape] of [ThemeData.checkboxTheme]
/// is used. If that's null then the shape will be a [RoundedRectangleBorder]
/// with a circular corner radius of 1.0.
final OutlinedBorder? checkboxShape;
/// If non-null, defines the background color when [CheckboxListTile.selected] is true. /// If non-null, defines the background color when [CheckboxListTile.selected] is true.
final Color? selectedTileColor; final Color? selectedTileColor;
...@@ -308,6 +316,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -308,6 +316,7 @@ class CheckboxListTile extends StatelessWidget {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus, autofocus: autofocus,
tristate: tristate, tristate: tristate,
shape: checkboxShape,
side: side, side: side,
); );
Widget? leading, trailing; Widget? leading, trailing;
......
...@@ -321,8 +321,8 @@ void main() { ...@@ -321,8 +321,8 @@ void main() {
expect(textColor('title'), activeColor); expect(textColor('title'), activeColor);
}); });
testWidgets('CheckboxListTile respects checkbox side', (WidgetTester tester) async { testWidgets('CheckboxListTile respects checkbox shape and side', (WidgetTester tester) async {
Widget buildApp(BorderSide side) { Widget buildApp(BorderSide side, OutlinedBorder shape) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
child: Center( child: Center(
...@@ -331,32 +331,47 @@ void main() { ...@@ -331,32 +331,47 @@ void main() {
value: false, value: false,
onChanged: (bool? newValue) {}, onChanged: (bool? newValue) {},
side: side, side: side,
checkboxShape: shape,
); );
}), }),
), ),
), ),
); );
} }
const RoundedRectangleBorder border1 = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));
const BorderSide side1 = BorderSide( const BorderSide side1 = BorderSide(
color: Color(0xfff44336), color: Color(0xfff44336),
); );
await tester.pumpWidget(buildApp(side1)); await tester.pumpWidget(buildApp(side1, border1));
expect(tester.widget<CheckboxListTile>(find.byType(CheckboxListTile)).side, side1); expect(tester.widget<CheckboxListTile>(find.byType(CheckboxListTile)).side, side1);
expect(tester.widget<CheckboxListTile>(find.byType(CheckboxListTile)).checkboxShape, border1);
expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side1); expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side1);
expect(tester.widget<Checkbox>(find.byType(Checkbox)).shape, border1);
expect( expect(
Material.of(tester.element(find.byType(Checkbox))), Material.of(tester.element(find.byType(Checkbox))),
paints paints
..drrect(color: const Color(0xfff44336)), ..drrect(
color: const Color(0xfff44336),
outer: RRect.fromLTRBR(11.0, 11.0, 29.0, 29.0, const Radius.circular(5)),
inner: RRect.fromLTRBR(12.0, 12.0, 28.0, 28.0, const Radius.circular(4)),
),
); );
const RoundedRectangleBorder border2 = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));
const BorderSide side2 = BorderSide( const BorderSide side2 = BorderSide(
width: 4.0,
color: Color(0xff424242), color: Color(0xff424242),
); );
await tester.pumpWidget(buildApp(side2)); await tester.pumpWidget(buildApp(side2, border2));
expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side2); expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side2);
expect(tester.widget<Checkbox>(find.byType(Checkbox)).shape, border2);
expect( expect(
Material.of(tester.element(find.byType(Checkbox))), Material.of(tester.element(find.byType(Checkbox))),
paints paints
..drrect(color: const Color(0xff424242)), ..drrect(
color: const Color(0xff424242),
outer: RRect.fromLTRBR(11.0, 11.0, 29.0, 29.0, const Radius.circular(5)),
inner: RRect.fromLTRBR(15.0, 15.0, 25.0, 25.0, const Radius.circular(1)),
),
); );
}); });
......
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