title: Flutter : Custom TextFormField is not saving values onSaved
body: <p>onSaved is not saving my values in the main class from where i am calling this class</p>
  
  <p>i want to generate custom form as per api return data and bind the data in form and then it should validate as called on validate in flutter </p>
  
  <p>i have created custom textform field for generating form field</p>
  
  <p>from main class i am using listview with for loop to generate a list and then my form is going to validate</p>
  
  <pre><code>class CustomTextField extends StatefulWidget {
  CustomTextField(
    {@required this.focusNode,
    @required this.nextFocusNode,
    @required this.textEditingController,
    @required this.validator,
    @required this.labelText,
    @required this.dataText});
  
  final FocusNode focusNode;
  final FocusNode nextFocusNode;
   final TextEditingController textEditingController;
   final FormFieldValidator&lt;String&gt; validator;
  
   final String labelText;
   String dataText;
  
    @override
    _CustomTextFieldState createState() =&gt; new _CustomTextFieldState();
   }
  
   class _CustomTextFieldState extends State&lt;CustomTextField&gt; {
        @override
    Widget build(BuildContext context) {
      return Container(
          height: 65,
          child: new TextFormField(
              style: Utility.textFormFieldStyle(context),
          keyboardType: TextInputType.text,
          textInputAction: widget.nextFocusNode == null
              ? TextInputAction.done
              : TextInputAction.next,
          focusNode: widget.focusNode,
          onFieldSubmitted: (v) {
            FocusScope.of(context).requestFocus(widget.nextFocusNode);
          },
          decoration: InputDecoration(
              labelText: widget.labelText,
              contentPadding: Utility.edgeInsetsGeometry()),
          controller: widget.textEditingController,
          validator: widget.validator,
          onSaved: (String val) {
  
  
            widget.dataText = val;
            // not saving my value in my main class
  
            print("costom text view ${widget.dataText}");
          }));
      }
   }
  
    ///    main class ----- belo code is run from a stateful class   ----------------------///
  
  
  
  List&lt;FocusNode&gt; listFocusNode;
   List&lt;String&gt; listDataText;
   List&lt;TextEditingController&gt; listTextEditingController;
   List&lt;Widget&gt; listFormField;
  
    @override
    void initState() {
     super.initState();
  
     listFocusNode = &lt;FocusNode&gt;[];
  listTextEditingController = &lt;TextEditingController&gt;[];
  listFormField = &lt;Widget&gt;[];
  listDataText = &lt;String&gt;[];
  
  for (int i = 0; i &lt; 5; i++) {
    listFocusNode.add(FocusNode());
  }
  
  for (int i = 0; i &lt; 5; i++) {
    listDataText.add("old");
  }
  
  for (int i = 0; i &lt; 5; i++) {
    listTextEditingController.add(TextEditingController());
  }
  
  for (int i = 0; i &lt; 5; i++)  {
    listFormField.add(CustomTextField(
      dataText: listDataText[i],
      focusNode: listFocusNode[i],
      labelText: "field$i",
      textEditingController: listTextEditingController[i],
      nextFocusNode: i == 4 ? null : listFocusNode[i + 1],
   //        validator: validateNull,
      validator: validateName,
       ));
     }
     }
  
    _validateForm() {
  if (_key.currentState.validate()) {
    // No any error in validation
    _key.currentState.save();
  
    print("Name ${listDataText.toString()}");
  
    // when i print this data in log its printing old data only but onSaved should save value to the proper location in array list
  
  
  
    Navigator.of(context).pop();
  } else {
    setState(() {
      _validate = true;
    });
  }
  </code></pre>
  
  <p>}</p>