setDay method
Implementation
void setDay(int day) {
if (day < 1 || day > 32) {
throw StateError('day must be specified in range 1-32');
}
if (state.selectedDate != null) {
var newDate =
DateTime(state.selectedDate!.year, state.selectedDate!.month, day);
// This can happen for example when the month only has 28 days, but the
// previous month had 31. Pretend like nothing happened
if (newDate.month > state.selectedDate!.month) {
return;
}
emit(state.copyWith(
selectedDate: newDate, availableDays: _calcAvailableDays(newDate)));
}
}