Unverified Commit ccf83d1d authored by xubaolin's avatar xubaolin Committed by GitHub

update CupertinoPicker.selectionOverlay to nullable (#79620)

parent 2c454a75
......@@ -198,7 +198,7 @@ class CupertinoPicker extends StatefulWidget {
/// If unspecified, it defaults to a [CupertinoPickerDefaultSelectionOverlay]
/// which is a gray rounded rectangle overlay in iOS 14 style.
/// This property can be set to null to remove the overlay.
final Widget selectionOverlay;
final Widget? selectionOverlay;
@override
State<StatefulWidget> createState() => _CupertinoPickerState();
......@@ -301,7 +301,8 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
),
),
),
_buildSelectionOverlay(widget.selectionOverlay),
if (widget.selectionOverlay != null)
_buildSelectionOverlay(widget.selectionOverlay!),
],
),
);
......
......@@ -172,6 +172,29 @@ void main() {
expect(find.byType(CupertinoPicker), paints..rrect(color: const Color(0x12345678)));
});
testWidgets('CupertinoPicker.selectionOverlay is nullable', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light),
home: Align(
alignment: Alignment.topLeft,
child: SizedBox(
height: 300.0,
width: 300.0,
child: CupertinoPicker(
itemExtent: 15.0,
children: const <Widget>[Text('1'), Text('1')],
onSelectedItemChanged: (int i) {},
selectionOverlay: null,
),
),
),
),
);
expect(find.byType(CupertinoPicker), isNot(paints..rrect()));
});
group('scroll', () {
testWidgets(
'scrolling calls onSelectedItemChanged and triggers haptic feedback',
......
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