jifalops / datetime_picker_formfield

A Flutter widget that wraps a TextFormField and integrates the date and/or time picker dialogs.
MIT License
186 stars 101 forks source link

Set datepicker value while clicked on a radio button #127

Closed pasha13d closed 2 years ago

pasha13d commented 2 years ago

I've a DateTimeFormField and a radio button. User can select date using DateTimeFormField but while user clicked on Yes Radio button I need to set DateTimeFormField value to DateTime.now(). I'm using setState(){} to set the value into datepicker while clicked on Yes radio button. But the isn't instantly viewed on DateTimeFormField . How could I acvieve that? I need to reset the DateTimeFormField value instantly.

pasha13d commented 2 years ago

I've solved the issue using Key.

DateTimeFormField (
  key: Key(value.toString),
  initialValue: value.toString
)

Then applied DateTimeFormField changing condition inside Radio button's. This will instantly changes DateTimeFormField value while clicking on others Radio button's.