getController method
Get a TextEditingController associated with a form attribute.
The getController function is used to retrieve a TextEditingController
associated with a specific form attribute. It ensures that a unique controller
is created and associated with the attribute. If a controller already exists
for the attribute, it returns that existing controller.
Parameters:
attribute: The identifier of the form attribute for which you want to retrieve theTextEditingController.
Returns:
A TextEditingController associated with the specified form attribute.
Implementation
TextEditingController getController(String attribute) {
late TextEditingController controller;
if (_controllers[attribute] == null) {
controller = TextEditingController();
_controllers[attribute] = controller;
}
controller = _controllers[attribute]!;
return controller;
}