diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index 83bfc45c12..e095411a63 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -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, ), ), ); diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 27b016a22e..e707334913 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -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. diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 62962ad609..3db380800b 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -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, ), ), ); diff --git a/packages/flutter/test/material/checkbox_list_tile_test.dart b/packages/flutter/test/material/checkbox_list_tile_test.dart index 45487ee5e2..4fcb66db24 100644 --- a/packages/flutter/test/material/checkbox_list_tile_test.dart +++ b/packages/flutter/test/material/checkbox_list_tile_test.dart @@ -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(find.byType(InkWell)).customBorder, shapeBorder); + }); } diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart index 0098a95cb0..053173b4e4 100644 --- a/packages/flutter/test/material/switch_list_tile_test.dart +++ b/packages/flutter/test/material/switch_list_tile_test.dart @@ -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(find.byType(InkWell)).customBorder, shapeBorder); + }); }