Unverified Commit 7f1540f3 authored by Anurag Roy's avatar Anurag Roy Committed by GitHub

Add contentPadding property for RadioListTile (#67438)

Exposes contentPadding property for RadioListTile from its appropriate ListTile.
parent 053ebf2c
...@@ -319,6 +319,7 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -319,6 +319,7 @@ class RadioListTile<T> extends StatelessWidget {
this.selected = false, this.selected = false,
this.controlAffinity = ListTileControlAffinity.platform, this.controlAffinity = ListTileControlAffinity.platform,
this.autofocus = false, this.autofocus = false,
this.contentPadding,
}) : assert(toggleable != null), }) : assert(toggleable != null),
assert(isThreeLine != null), assert(isThreeLine != null),
...@@ -469,6 +470,14 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -469,6 +470,14 @@ class RadioListTile<T> extends StatelessWidget {
/// {@macro flutter.widgets.Focus.autofocus} /// {@macro flutter.widgets.Focus.autofocus}
final bool autofocus; final bool autofocus;
/// Defines the insets surrounding the contents of the tile.
///
/// Insets the [Radio], [title], [subtitle], and [secondary] widgets
/// in [RadioListTile].
///
/// When null, `EdgeInsets.symmetric(horizontal: 16.0)` is used.
final EdgeInsetsGeometry? contentPadding;
/// Whether this radio button is checked. /// Whether this radio button is checked.
/// ///
/// To control this value, set [value] and [groupValue] appropriately. /// To control this value, set [value] and [groupValue] appropriately.
...@@ -519,6 +528,7 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -519,6 +528,7 @@ class RadioListTile<T> extends StatelessWidget {
} : null, } : null,
selected: selected, selected: selected,
autofocus: autofocus, autofocus: autofocus,
contentPadding: contentPadding,
), ),
), ),
); );
......
...@@ -606,4 +606,44 @@ void main() { ...@@ -606,4 +606,44 @@ void main() {
await tester.pump(); await tester.pump();
expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse); expect(Focus.of(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
}); });
testWidgets('RadioListTile contentPadding test', (WidgetTester tester) async {
final Type radioType = const Radio<bool>(
groupValue: true,
value: true,
onChanged: null,
).runtimeType;
await tester.pumpWidget(
wrap(
child: Center(
child: RadioListTile<bool>(
groupValue: true,
value: true,
title: const Text('Title'),
onChanged: (_){},
contentPadding: const EdgeInsets.fromLTRB(8, 10, 15, 20),
)
)
)
);
final Rect paddingRect = tester.getRect(find.byType(Padding));
final Rect radioRect = tester.getRect(find.byType(radioType));
final Rect titleRect = tester.getRect(find.text('Title'));
// Get the taller Rect of the Radio and Text widgets
final Rect tallerRect = radioRect.height > titleRect.height ? radioRect : titleRect;
// Get the extra height between the tallerRect and ListTile height
final double extraHeight = 56 - tallerRect.height;
// Check for correct top and bottom padding
expect(paddingRect.top, tallerRect.top - extraHeight / 2 - 10); //top padding
expect(paddingRect.bottom, tallerRect.bottom + extraHeight / 2 + 20); //bottom padding
// Check for correct left and right padding
expect(paddingRect.left, radioRect.left - 8); //left padding
expect(paddingRect.right, titleRect.right + 15); //right padding
});
} }
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