GaspardMerten / date_field

Flutter DateField and DateFormField
Other
46 stars 32 forks source link

Cancel time selection returns date with time 00:00:00 #53

Closed PedroPinheiro closed 10 months ago

PedroPinheiro commented 11 months ago

My pubspec.yaml

environment:
  sdk: ">=3.2.1 <4.0.0"
  flutter: 3.16.1
dependencies:
  ...
  date_field: ^3.0.5
  ...

How to reproduce

1) Given the date time field (It has the default mode: DateTimeFieldPickerMode.dateAndTime):

  DateTimeField(
    use24hFormat: true,
    key: const ValueKey<String>('date-time-field-start'),
    onDateSelected: (value) {
      log('Date Selected: $value');
      setState(() {
        selectedStart = value;
      });
    },
    selectedDate: selectedStart,
  )

2) The DateTimeField receives a date like "2023-12-14 21:15:33" from selectedStart variable. 3) User taps on the date time field, to open the Date Picker. 4) User taps on "OK" button to open the the Time Picker. 5) User taps "Cancel" on Time Picker 6) The value returned is "2023-12-14 21:15:33"

Expected behaviour

In my opinion the expected behaviour should be returning the date with the previous time.

Example: