I have a form with about 15 textform fields to input data by the user. What is the best solution for this?
I have currently created a list like below:
List<TextEditingController> textController = [
TextEditingController(), //name
TextEditingController(), //location
TextEditingController(), //days
TextEditingController(), //year
TextEditingController(), //hour
TextEditingController(), //minutes
TextEditingController(), //seconds
TextEditingController(), //lat_dec
TextEditingController(), //lng_dec
TextEditingController(), //lat_deg
TextEditingController(), //lat_min
TextEditingController(), //lat_sec
TextEditingController(), //lng_deg
TextEditingController(), //lng_min
TextEditingController(), //lat_sec
];
Can I reuse the the same TextEditingController to avoid so many variables? Any suggestions?
using the same
TextEditingControllerfor more thanTextFieldhas unexpected behavior which is:The text you are typing in a specific field will be simultaneously written to other fields that are controlled with the same controller.
so, try to handle it through creating a
map of controllersor even generate alistwith specific length of controllers.