Unverified Commit 2b33dae9 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Add Border customization to CheckboxListTile (reprise) (#93271)

parent aaf1003a
...@@ -301,8 +301,9 @@ class Checkbox extends StatefulWidget { ...@@ -301,8 +301,9 @@ class Checkbox extends StatefulWidget {
/// compatibility. /// compatibility.
/// {@endtemplate} /// {@endtemplate}
/// ///
/// If this property is null then [CheckboxThemeData.side] of [ThemeData.checkboxTheme] /// If this property is null, then [CheckboxThemeData.side] of
/// is used. If that's null then the side will be width 2. /// [ThemeData.checkboxTheme] is used. If that is also null, then the side
/// will be width 2.
final BorderSide? side; final BorderSide? side;
/// The width of a checkbox widget. /// The width of a checkbox widget.
......
...@@ -138,6 +138,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -138,6 +138,7 @@ class CheckboxListTile extends StatelessWidget {
this.tristate = false, this.tristate = false,
this.shape, this.shape,
this.selectedTileColor, this.selectedTileColor,
this.side,
this.visualDensity, this.visualDensity,
this.focusNode, this.focusNode,
this.enableFeedback, this.enableFeedback,
...@@ -258,6 +259,15 @@ class CheckboxListTile extends StatelessWidget { ...@@ -258,6 +259,15 @@ class CheckboxListTile extends StatelessWidget {
/// 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;
/// {@macro flutter.material.checkbox.side}
///
/// The given value is passed directly to [Checkbox.side].
///
/// If this property is null, then [CheckboxThemeData.side] of
/// [ThemeData.checkboxTheme] is used. If that is also null, then the side
/// will be width 2.
final BorderSide? side;
/// Defines how compact the list tile's layout will be. /// Defines how compact the list tile's layout will be.
/// ///
/// {@macro flutter.material.themedata.visualDensity} /// {@macro flutter.material.themedata.visualDensity}
...@@ -298,6 +308,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -298,6 +308,7 @@ class CheckboxListTile extends StatelessWidget {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
autofocus: autofocus, autofocus: autofocus,
tristate: tristate, tristate: tristate,
side: side,
); );
Widget? leading, trailing; Widget? leading, trailing;
switch (controlAffinity) { switch (controlAffinity) {
......
...@@ -321,6 +321,45 @@ void main() { ...@@ -321,6 +321,45 @@ void main() {
expect(textColor('title'), activeColor); expect(textColor('title'), activeColor);
}); });
testWidgets('CheckboxListTile respects checkbox side', (WidgetTester tester) async {
Widget buildApp(BorderSide side) {
return MaterialApp(
home: Material(
child: Center(
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return CheckboxListTile(
value: false,
onChanged: (bool? newValue) {},
side: side,
);
}),
),
),
);
}
const BorderSide side1 = BorderSide(
color: Color(0xfff44336),
);
await tester.pumpWidget(buildApp(side1));
expect(tester.widget<CheckboxListTile>(find.byType(CheckboxListTile)).side, side1);
expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side1);
expect(
Material.of(tester.element(find.byType(Checkbox))),
paints
..drrect(color: const Color(0xfff44336)),
);
const BorderSide side2 = BorderSide(
color: Color(0xff424242),
);
await tester.pumpWidget(buildApp(side2));
expect(tester.widget<Checkbox>(find.byType(Checkbox)).side, side2);
expect(
Material.of(tester.element(find.byType(Checkbox))),
paints
..drrect(color: const Color(0xff424242)),
);
});
testWidgets('CheckboxListTile respects visualDensity', (WidgetTester tester) async { testWidgets('CheckboxListTile respects visualDensity', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
Future<void> buildTest(VisualDensity visualDensity) async { Future<void> buildTest(VisualDensity visualDensity) async {
......
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