Skip to content

Commit 08ccbc9

Browse files
Merge pull request #1444 from geronimol/date-picker-cancel-behavior
fix: DateTime Picker "cancel" button behavior fix
2 parents d249ef6 + e7b3f94 commit 08ccbc9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/fields/form_builder_date_time_picker.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
307307
if (date != null) {
308308
if (!mounted) break;
309309
final time = await _showTimePicker(currentValue);
310-
newValue = combine(date, time);
310+
if (time == null) {
311+
newValue = null;
312+
} else {
313+
newValue = combine(date, time);
314+
}
311315
}
312316
break;
313317
}
@@ -360,7 +364,7 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
360364
};
361365
}
362366

363-
final timePickerResult = await showTimePicker(
367+
return await showTimePicker(
364368
context: context,
365369
initialTime: currentValue != null
366370
? TimeOfDay.fromDateTime(currentValue)
@@ -377,8 +381,6 @@ class _FormBuilderDateTimePickerState extends FormBuilderFieldDecorationState<
377381
onEntryModeChanged: widget.onEntryModeChanged,
378382
barrierDismissible: widget.barrierDismissible,
379383
);
380-
return timePickerResult ??
381-
(currentValue != null ? TimeOfDay.fromDateTime(currentValue) : null);
382384
}
383385

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

0 commit comments

Comments
 (0)