Read page as text

NIB / DOCUMENTATION

Date picker — NibComponents

Select a date, a range, or a set of days in a bounded calendar.

Open interactive view

Match the callback to the mode

NibDatePickerMode.single emits DateTime? through onDateChanged. range emits NibDateRange? through onRangeChanged; end remains null until the second pick and isComplete tells you whether both endpoints exist. multi emits the complete date list through onDatesChanged. Values are normalized to calendar days rather than time-of-day appointments.

Choose inline, popover, or dialog

NibDatePickerDisplayMode.inline is the default. Popover places a trigger and nearest-overlay calendar beside it; dialog centers the calendar in that same nearest overlay. This date-picker dialog is distinct from the root-overlay showNibDialog helper. closeOnSelect defaults to true: single closes after one pick, range after completion, and multi remains open.

Read and drive the calendar deliberately

NibDatePickerController owns selectedDate, selectedRange, selectedDates, displayedMonth, and isOpen. Seed it once; the matching controller getter is meaningful for the active mode. setSingle, setRange, setMulti, clear, showMonth, open, and close change those states. setSelectableBounds supplies runtime bounds that take precedence over widget bounds. Dispose the controller you create.

Disable days without inventing availability

minDate, maxDate, and NibDisabledDayPredicate restrict selection. The fixture covers October–December 2026 and optionally disables Sundays. These are sample business rules, not a current availability service. A server must validate an accepted date again if availability can change.

Customize cells and keep their interaction

NibDateCellShape offers circle, rounded, square, and pill. NibCalendarDayBuilder receives NibCalendarDayState: date, selected, inRange, isRangeStart, isRangeEnd, today, outOfMonth, and disabled. Return only the cell content; the calendar retains its tap target and 44-pixel sizing. A custom builder supersedes built-in cell appearance.

Use the host locale and optional motion

locale: null uses the surrounding MaterialLocalizations; an explicit locale overrides labels where the host supports it. animated defaults to false and opts into calendar transitions and selection feedback. The demo keeps the displayed month stable during unrelated control changes.

A selected value or date range seems wrong

Controller state overrides the initial widget selections. Pick two endpoints before treating a range as complete. Date-only comparison is intentional; do not send local midnight as an absolute instant without your own time-zone contract. A calendar scaled to a narrow preview is not physical-device or screen-reader verification.