Skip to content

Commit

Permalink
Merge pull request #1444 from geronimol/date-picker-cancel-behavior
Browse files Browse the repository at this point in the history
fix: DateTime Picker "cancel" button behavior fix
  • Loading branch information
deandreamatias authored Dec 18, 2024
2 parents d249ef6 + e7b3f94 commit 08ccbc9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/src/fields/form_builder_date_time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
if (date != null) {
if (!mounted) break;
final time = await _showTimePicker(currentValue);
newValue = combine(date, time);
if (time == null) {
newValue = null;
} else {
newValue = combine(date, time);
}
}
break;
}
Expand Down Expand Up @@ -360,7 +364,7 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
};
}

final timePickerResult = await showTimePicker(
return await showTimePicker(
context: context,
initialTime: currentValue != null
? TimeOfDay.fromDateTime(currentValue)
Expand All @@ -377,8 +381,6 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
onEntryModeChanged: widget.onEntryModeChanged,
barrierDismissible: widget.barrierDismissible,
);
return timePickerResult ??
(currentValue != null ? TimeOfDay.fromDateTime(currentValue) : null);
}

/// Sets the hour and minute of a [DateTime] from a [TimeOfDay].
Expand Down

0 comments on commit 08ccbc9

Please sign in to comment.