简体   繁体   中英

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

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 ie Save and Cancel will appear.

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

Thank you.

  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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM