title: how to validate dynamically created textfields in flutter
body: <p><strong>the value of the boolean variable changes but it doesn't show error text on text field</strong></p>
  
  <p><em>these are the declarations</em>    </p>
  
  <pre><code>    int i = 0;
      List&lt;bool&gt; validationList = [];
      List&lt;Widget&gt; listDynamic = [];
      List&lt;TextEditingController&gt; controllersList = []; 
  </code></pre>
  
  <p><em>this is the method for validation</em></p>
  
  <pre><code>    submitData()
      {
      for(int a = 0 ; a &lt; i; a++ ){
          if(controllersList[a].text == ''){
              setState(() {
                  validationList[a] =true;
                  print(validationList[a]);
              });
          }
      }
      }
  </code></pre>
  
  <p><em>this is the method for creating text fileds dynamically</em></p>
  
  <pre><code>    addDynamic() {
      validationList = List.from(validationList)..add(false);
      controllersList = List.from(controllersList)..add(TextEditingController());
      listDynamic = List.from(listDynamic)..add(Column(
          children: &lt;Widget&gt;[
              Container(
              margin: EdgeInsets.fromLTRB(20, 40, 20, 0),
              child: TextField(
                  decoration: InputDecoration(
                      errorText: validationList[i] == true ? 'Value cant be empty' : null,
                      labelText: ('ImageURL'),
                      prefixIcon: Icon(Icons.image),
                      helperText: 'www.example.com',
                      border: OutlineInputBorder()),
                      controller: controllersList[i],
              ),
            ),
            SizedBox(height: 20),
          ],
        ));
        i++;
      setState(() {});
      }
  </code></pre>