selectionOverlayBuilder property
final
A function that returns a widget that is overlaid on the picker to highlight the currently selected entry.
If unspecified, it defaults to a CupertinoPickerDefaultSelectionOverlay which is a gray rounded rectangle overlay in iOS 14 style.
If the selection overlay builder returns null, no overlay will be drawn.
This example shows how to recreate the default selection overlay
with selectionOverlayBuilder.
link
CupertinoDatePicker(
onDateTimeChanged: (DateTime newDateTime) {},
mode: CupertinoDatePickerMode.date,
initialDateTime: DateTime(2018, 9, 15),
selectionOverlayBuilder: (
BuildContext context, {
required int selectedIndex,
required int columnCount,
}) {
if (selectedIndex == 0) {
return const CupertinoPickerDefaultSelectionOverlay(
capEndEdge: false,
);
} else if (selectedIndex == columnCount - 1) {
return const CupertinoPickerDefaultSelectionOverlay(
capStartEdge: false,
);
}
return const CupertinoPickerDefaultSelectionOverlay(
capStartEdge: false,
capEndEdge: false,
);
},
)
Implementation
final SelectionOverlayBuilder? selectionOverlayBuilder;