Future builder

A future builder is a widget that can run futures

First, you need to create a future:

Future<String> nameOfFuture (String url) async {
//code
  return //code;
}

And later create the future builder connected to the future created previously:

FutureBuilder(
          future: nameOfFuture(),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
               return // code of what to do when is waiting for response
             } else {
               return // code of what to do when the response is here!
               // The response is returned in the "snapshot" variable
               );
             }
           },
         ),

Last updated