Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormBuilderDateTimePicker onChanged callback returns incorrect date #164

Closed
opringle opened this issue Oct 31, 2019 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@opringle
Copy link

Bug

When using the callback onChanged with FormBuilderDateTimePicker it returns dates from 1970, rather than the date the user selected!

Steps to reproduce

  • Create a form
  • Add this form and use it
 FormBuilderDateTimePicker(
                initialDate: DateTime.now(),
                onChanged: (DateTime d){
                  print("SELECTED DATETIME: $d");
                },
                attribute: "startTime",
                inputType: InputType.both,
                format: DateFormat("EEEE MMM d kk:mm"),
                decoration:
                    InputDecoration(labelText: "Enter a time and view logs"),
              ),
@danvick
Copy link
Collaborator

danvick commented Nov 2, 2019

Hi @opringle,
Thanks for bringing this to my attention. I'll test and work on a fix ASAP.

@danvick danvick added the bug Something isn't working label Nov 2, 2019
@danvick
Copy link
Collaborator

danvick commented Nov 3, 2019

Seems this bug is caused by the underlying library, datetime_picker_formfield, which when submitting it tries to parse the string in the TextField back to a DateTime. But since your DateFormat lacks the year field, it is substituted by 1970.

This issue has already been reported in the library.

I'll try to do a workaround for the benefit of our library.

@danvick danvick closed this as completed in c0b4dea Nov 4, 2019
@danvick
Copy link
Collaborator

danvick commented Nov 4, 2019

Hi @opringle,
Kindly check out v3.6.0. It contains a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants