'Flutter clear input form value during Edit

I have an edit form contains input field, dropdown, radio button, date field. I've displayed all the available values that were used gave input before. I've to clear the form if the user gave input some new value and thought not to Edit/Update. Then user clicked on the Cancel button. While clicking on the cancel button I've to clear the whole page except the saved value that's displayed in the edit form. I've tried using this

final _peopleForm = GlobalKey<FormState>();
_peopleForm.currentState?.reset(); // reset the value

But this will clear only the input field. The selected value in the dropdown/radio button/ date field isn't cleared. How can I clear all the forms by clicking on the Cancel Button



Solution 1:[1]

It's because your dropdown, radio button and date field doesn't embed FormField by default.

You could use some package if you want it to be done :

  • dropdown_formfield
  • radio_button_form_field
  • datetime_picker_formfield

Note : sorry i put the first thing I've googled

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arnaud