title: How to update TextFormField content after onPressed of a prefixIcon with FutureBuilder?
body: <p>I just started a small flutter project. I have a onPressed property inside a suffixIcon and the onPressed itself has a FutureBuilder inside of it. The future function is async (I am using the geolocator package) and it returns the coordinates of the device. I want to refresh the TextFieldForm content with those coordinates when the user presses the suffixIcon but the TextFieldForm is not being updated, although the onPressed is working as I have a print in the function to know if it's working properly. Here is the code of the TextFormBuilder, and below is the complete code. Any help would be apreciated</p>
  <pre><code>TextFormField(
                controller: myController,
                decoration: InputDecoration(
                  prefixIcon: IconButton(
                    icon: Icon(Icons.location_searching),
                    onPressed:(){
                      FutureBuilder&lt;String&gt;(
                        future: _obtenerUbicacion(),
                        builder: (context, snapshot) {
                          if (snapshot.hasData) {
                            myController.text =  snapshot.data;
                          } else if (snapshot.hasError) {
                            return Text(&quot;${snapshot.error}&quot;);
                          }
                          // By default, show a loading spinner.
                          return CircularProgressIndicator();
                        },
                      );
                    }
                    ,
                  ),
                  hintText: 'Ingrese su ubicación',
                ),
                validator: (value) {
                  if (value.isEmpty) {
                    return 'Por favor ingrese su ubicación';
                  }
                  return null;
                },
              ),
  </code></pre>
  <p>Here is the complete code of the App</p>
  <pre><code>import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'dart:async';
  import 'dart:convert';
  import 'package:geolocator/geolocator.dart';
  
  
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
          theme: ThemeData(primaryColor: Colors.deepOrangeAccent[100]),
          home: Localizador());
    }
  }
  
  class Localizador extends StatefulWidget {
    @override
    _LocalizadorState createState() =&gt; _LocalizadorState();
  }
  
  class _LocalizadorState extends State&lt;Localizador&gt; {
    final _formKey = GlobalKey&lt;FormState&gt;();
    Future&lt;Serviciabilidad&gt; futureServiciabilidad;
    final myController = TextEditingController();
  
    @override
    Widget _coordenadas() {
      return Padding(
        padding: const EdgeInsets.all(15.0),
        child: Form(
          key: _formKey,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: &lt;Widget&gt;[
              TextFormField(
                controller: myController,
                decoration: InputDecoration(
                  prefixIcon: IconButton(
                    icon: Icon(Icons.location_searching),
                    onPressed:(){
                      FutureBuilder&lt;String&gt;(
                        future: _obtenerUbicacion(),
                        builder: (context, snapshot) {
                          if (snapshot.hasData) {
                            myController.text =  snapshot.data;
                          } else if (snapshot.hasError) {
                            return Text(&quot;${snapshot.error}&quot;);
                          }
                          // By default, show a loading spinner.
                          return CircularProgressIndicator();
                        },
                      );
                    }
                    ,
                  ),
                  hintText: 'Ingrese su ubicación',
                ),
                validator: (value) {
                  if (value.isEmpty) {
                    return 'Por favor ingrese su ubicación';
                  }
                  return null;
                },
              ),
              Padding(
                padding: const EdgeInsets.symmetric(vertical: 16.0),
                child: RaisedButton(
                  onPressed: () {
                    // Validate will return true if the form is valid, or false if
                    // the form is invalid.
                    if (_formKey.currentState.validate()) {
                      futureServiciabilidad = obtenerServiciabilidad();
                    }
                  },
                  child: Text('Enviar'),
                ),
              ),
            ],
          ),
        ),
      );
    }
  
    Widget build(BuildContext context) {
      return Scaffold(appBar: AppBar(title: Text('MyAPP')), body: _coordenadas());
    }
  }
  
  Future&lt;String&gt; _obtenerUbicacion() async {
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    //print(position.toString());
    String pos = (position.latitude.toString())+ &quot; &quot; + (position.longitude.toString());
    print(pos);
    return pos;
  }
  </code></pre>