selectionOverlayBuilder property

SelectionOverlayBuilder? selectionOverlayBuilder
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.

{@tool snippet}

This example shows how to recreate the default selection overlay with selectionOverlayBuilder.

CupertinoTimerPicker(
  onTimerDurationChanged: (Duration newDateTime) {},
  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,
    );
  },
)

{@end-tool}

Implementation

final SelectionOverlayBuilder? selectionOverlayBuilder;