title: pass variables by parameters to be modified within the function
body: <p>I have a method that takes care of the logic of saving the values of the <strong>TextFormField</strong> fields in variables, of different <strong>Forms</strong>, but they do not save the value in the <strong>String</strong> variables that I pass through parameters, when the <strong>Forms</strong> are validated.</p>
  
  <p>This is the declaration of my variables from one of the forms:</p>
  
  <pre><code>    final formKeyMotherboard = new GlobalKey&lt;FormState&gt;();
    String _numInvMotherboard,
        _marcaMotherboard,
        _modeloMotherboard,
        _tipoMotherboard,
        _detallesMotherboard,
        _fechaMotherboard;
  
    final TextEditingController controllerNumInventarioMotherboard =
        new TextEditingController();
    final TextEditingController controllerMarcaMotherboard =
        new TextEditingController();
    final TextEditingController controllerModeloMotherboard =
        new TextEditingController();
    final TextEditingController controllerTipoMotherboard =
        new TextEditingController();
    final TextEditingController controllerDetallesMotherboard =
        new TextEditingController();
    final TextEditingController controllerFechaMotherboard =
        new TextEditingController();
  </code></pre>
  
  <p>This is the method:</p>
  
  <pre><code>    Step _defaulFrom(
        {@required IconData icon,
        @required String nameForm,
        @required Key keyForm,
        @required String saveNumInv,
        @required String saveMarca,
        @required String saveModelo,
        @required String saveTipo,
        @required String saveDetalles,
        @required String saveFecha,
        @required TextEditingController controllerNumInv,
        @required TextEditingController controllerMarca,
        @required TextEditingController controllerModelo,
        @required TextEditingController controllerTipo,
        @required TextEditingController controllerDetalle,
        @required TextEditingController controllerFecha,
        TextEditingController controllerEncargado,
        String saveEncargado}) {
      return Step(
          title: Text(
            nameForm,
            style: TextStyle(
              color: Colors.black45,
              fontSize: 22.0,
              fontWeight: FontWeight.bold,
            ),
          ),
          content: Form(
              key: keyForm,
              child: Padding(
                padding: const EdgeInsets.all(12.0),
                child: Column(
                  children: &lt;Widget&gt;[
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        controller: controllerNumInv,
                        autocorrect: false,
                        decoration: _defaulImputDecoration(NUM_INVENTARIO, icon),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        `enter code here`onSaved: (value) =&gt; saveNumInv = value,
  
                        keyboardType: TextInputType.numberWithOptions(),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        controller: controllerMarca,
                        autocorrect: false,
                        decoration: _defaulImputDecoration(MARCA, icon),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        onSaved: (value) =&gt; saveMarca = value,
  
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        controller: controllerModelo,
                        autocorrect: false,
                        decoration: _defaulImputDecoration(MODELO, icon),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        onSaved: (value) =&gt; saveModelo = value,
  
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        controller: controllerTipo,
                        autocorrect: false,
                        decoration: _defaulImputDecoration(TIPO, icon),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        onSaved: (value) =&gt; saveTipo = value,
  
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        controller: controllerDetalle,
                        autocorrect: false,
                        decoration: _defaulImputDecoration(DETALLES, icon),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        onSaved: (value) =&gt; saveDetalles = value,
  
                      ),
                    ),
                    controllerEncargado != null
                        ? Padding(
                            padding: const EdgeInsets.only(top: 8.0),
                            child: TextFormField(
                              controller: controllerEncargado,
                              autocorrect: false,
                              decoration: _defaulImputDecoration(
                                  NOMBRE_ENCARGADO, Icons.person),
                              validator: (val) =&gt;
                                  val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                              onSaved: (value) =&gt; saveEncargado = value,
  
                            ),
                          )
                        : Divider(
                            color: Colors.transparent,
                          ),
                    Padding(
                      padding: const EdgeInsets.only(top: 8.0),
                      child: TextFormField(
                        autocorrect: false,
                        controller: controllerFecha,
                        decoration: InputDecoration(
                          suffixIcon: IconButton(
                              icon: Icon(Icons.date_range),
                              onPressed: () {
                                _selectDate(context);
                                setState(() {
                                  //_saveDate = new DateFormat.yMd(_dateTime)
                                });
                              }),
                          contentPadding: EdgeInsets.all(16.0),
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(25.0),
                          ),
                          labelText: 'Fecha',
                          labelStyle: TextStyle(
                              color: Colors.black54,
                              fontSize: 16.0,
                              decorationStyle: TextDecorationStyle.wavy),
                        ),
                        validator: (val) =&gt;
                            val.isEmpty ? ERROR_RELLENE_CAMPO : null,
                        onSaved: (value) =&gt; saveFecha = value,
  
                      ),
                    ),
  
                 }
  
                    })
                  ],
                ),
              )));
    }
  </code></pre>
  
  <p>With this method I want to reduce code, I have 5 forms that have the same code, the only thing that changes are the values where the values of the <strong>TextFormField</strong> obtained from the <strong>TextEditingController</strong> with <em>controller.text</em> are saved and saved, it tells me that its values are <strong>null</strong></p>