toggleUserPicked method
Toggles the selection state when a user taps a calendar day cell.
If isRangeSelection is enabled, the tap builds a range; otherwise,
a single date is picked and the _onUserPickedCallback
is fired.
Implementation
void toggleUserPicked(int index) {
if (isRangeSelection) {
if (_rangeStart == null || (_rangeStart != null && _rangeEnd != null)) {
_rangeStart = index;
_rangeEnd = null;
} else if (_rangeStart != null && _rangeEnd == null) {
_rangeEnd = index;
if (_rangeEnd! < _rangeStart!) {
final temp = _rangeStart;
_rangeStart = _rangeEnd;
_rangeEnd = temp;
}
}
if (_rangeStart != null && _rangeEnd != null) {
_onUserPickedCallback?.call(_getSelectedRangeDates());
}
} else {
_userPicked = index;
_onUserPickedCallback?.call([_getDateFromIndex(index)]);
}
notifyListeners();
}