GaspardMerten / date_field

Flutter DateField and DateFormField
Other
45 stars 32 forks source link

onSaved is never called for DateTimeFormField #17

Closed nikhilbawane closed 3 years ago

nikhilbawane commented 3 years ago

The function onSaved is not called when the date is selected or on tapping the OK button.

Reviewing the code I see that the constructor takes onSaved parameter, but isn't used anywhere in the code.

Ideally, I would expected it to return a value when the OK button is tapped.

GaspardMerten commented 3 years ago

Hello @nikhilbawane,

The "onSaved" method is not meant for what you describe (onDateSelected is the property you are looking for). If you look at the official documentation for the "onSaved" method, this is what you will find:

/// An optional method to call with the final value when the form is saved via /// [FormState.save].

Calling "formKey.currentState?.save()" for instance will trigger the DateTimeFormField to call onSaved.

To learn more about form key : Form Validation

I am closing this issue for now.