GaspardMerten / date_field

Flutter DateField and DateFormField
Other
45 stars 32 forks source link

DateTimeField should be a statelesswidget #10

Closed NANASHI0X74 closed 3 years ago

NANASHI0X74 commented 3 years ago

similar to #2 where datetimeformfield was a statelesswidget... I think datetimefield should be a statefulwidget as well... I see that in the example there's a datetimefield as a child of a statefulwidget and it sets the state of its parent, which if I intuit currectly causes the parent to be rebuilt along with the datetimefield. So in a stateful context you can make it update that way, but it would be much nicer if it already did that on its own. So I guess it would make sense to make it a statefulwidget and to setState along with calling the onDateChanged

GaspardMerten commented 3 years ago

I do not think that what you are proposing is the default behaviour for flutter widgets. If you could give me an example of an official Flutter widget with this behaviour then I would gladly make the changes you are proposing!

NANASHI0X74 commented 3 years ago

well it seems like the most obvious comparison would be to the textfield widget- https://api.flutter.dev/flutter/material/TextField-class.html which is a stateful widget

GaspardMerten commented 3 years ago

It's quite not the same, it stores its value using a TextEditingController not using a State, or does it?

NANASHI0X74 commented 3 years ago

well, it extends statefulwidget anyway. I would suspect that the controller is part of the state, but I don't have time right now to dig through the sources