onShowPicker method
- BuildContext context,
- DateTime? currentValue
Shows correct date or time picker for component.
Implementation
Future<void> onShowPicker(BuildContext context, DateTime? currentValue) async {
DateTime? newValue;
if (widget.mode == DateTimePickerMode.date) {
newValue = await _showDatePicker(context, currentValue);
} else if (widget.mode == DateTimePickerMode.time) {
final newTime = await _showTimePicker(context, currentValue);
newValue = newTime != null ? _convert(newTime) : null;
} else {
final date = await _showDatePicker(context, currentValue ?? DateTime.now());
if (date != null) {
if (mounted) {
final time = await _showTimePicker(context, currentValue ?? DateTime.now());
if (time != null) {
newValue = _combine(date, time);
}
}
}
}
setState(() {
_dateTime = newValue ?? currentValue;
widget.onChange?.call(_dateTime);
widget.controller?.notifyListeners(_dateTime);
});
}