'Undefined Name | Error in TextEditingController (''Flutter/Dart)

I have Error in "controller" it says undefined name 'profileNameTextEditingController'

language: Flutter/dart

My Activity :

Activity line 1-29
Error



Solution 1:[1]

Pass profileNameTextEditingController as argument to createProfileNameTextFormField and then use it in controller.

Column createProfileNameTextFormField(profileNameTextEditingController) {
  return Column(
    ...
    TextField(
      controller: profileNameTextEditingController,
    ),
  );
}

Solution 2:[2]

'profileNameTextEditingController' scope is only within the class _editProfileState. Just pass controller as argument to the function where its needed.

createProfileNameTextFormField(profileNameTextEditingController);

Column createProfileNameTextFormField(profileNameTextEditingController) {
  
}

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
Solution 2 THE FUSION