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

initialValue - timePicker defaults to 12:00 #234

Closed
Paul-Todd opened this issue Feb 28, 2020 · 3 comments
Closed

initialValue - timePicker defaults to 12:00 #234

Paul-Todd opened this issue Feb 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@Paul-Todd
Copy link

When using initialValue the time defaults to 12:00 instead of the time set in initialValue.

this is because at line 378 the order of the selection is wrong

 initialTime: widget.initialTime ?? TimeOfDay.fromDateTime(currentValue ?? DateTime.now()));

should actually be

initialTime: currentValue ? TimeOfDay.fromDateTime(currentValue) : widget.initialTime ? widget.initialTime : TimeOfDay.fromDateTime(DateTime.now());

initialTime has a runtime default value so that is getting chosen in preference to the current value.

@Paul-Todd
Copy link
Author

Or set initialTime: null in the constructor to force the time to come from the initialValue

@qwertyuiop17u
Copy link

I got the same problem.

And before this bug fixed, I use my own timePicker to fix it.
Just like following.
it works for me.

FormBuilderDateTimePicker(
    ...,
    timePicker: (BuildContext context){
        return showTimePicker(
            context: context, 
            initialTime: initialTime,
        ).then((result){
            return result ?? initialTime;
        });
    },
)

@danvick danvick added the bug Something isn't working label Mar 9, 2020
@danvick
Copy link
Collaborator

danvick commented Mar 9, 2020

Hi @Paul-Todd,
Thanks for bringing this to my attention, I'll be sure to fix this ASAP.

@danvick danvick closed this as completed in ca32d28 Mar 9, 2020
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

3 participants