select method

void select(
  1. DateTime date
)

Adds date per the current SelectionMode: replaces the selection in single mode, appends (or keeps) it in multiple mode, and sets or completes the range in range mode. No-op when detached or date is outside the rendered range. Does not scroll and fires no callbacks.

Implementation

void select(DateTime date) {
  final state = _datePickerState;
  if (state == null || state._indexOf(date) == null) return;
  final key = state._unitKey(date);
  // _nextSelection toggles in multiple mode; select() must be additive.
  if (state.widget.selectionMode == SelectionMode.multiple &&
      state._selectedKeys.contains(key)) {
    return;
  }
  state._applyProgrammaticSelection(state._nextSelection(key), anchor: key);
}