Best practice to use the same widget for view/edit mode in Flutter

Viewed 44

i am new to flutter and I building an application now. I have a general question. What is the best practice to use the same widget/page for view mode and edit mode. in View mode there will be an edit button when user clicks on it then fields will be open for edit and two buttons i.e. Save and Cancel will appear.

Should I create different widgets for each state or I should control this with some flags?

Thank you.

1 Answers
  1. if you are displaying the data inside the disabled text field, simply setting the flag will do the trick. But it can get complicated if there are many fields.

  2. If UI for displaying the data and showing the form are different, I would suggest you use different widgets

Related