mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
update CupertinoPicker.selectionOverlay to nullable (#79620)
This commit is contained in:
parent
2c454a7536
commit
ccf83d1de9
@ -198,7 +198,7 @@ class CupertinoPicker extends StatefulWidget {
|
|||||||
/// If unspecified, it defaults to a [CupertinoPickerDefaultSelectionOverlay]
|
/// If unspecified, it defaults to a [CupertinoPickerDefaultSelectionOverlay]
|
||||||
/// which is a gray rounded rectangle overlay in iOS 14 style.
|
/// which is a gray rounded rectangle overlay in iOS 14 style.
|
||||||
/// This property can be set to null to remove the overlay.
|
/// This property can be set to null to remove the overlay.
|
||||||
final Widget selectionOverlay;
|
final Widget? selectionOverlay;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _CupertinoPickerState();
|
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)));
|
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', () {
|
group('scroll', () {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'scrolling calls onSelectedItemChanged and triggers haptic feedback',
|
'scrolling calls onSelectedItemChanged and triggers haptic feedback',
|
||||||
|
Loading…
Reference in New Issue
Block a user