Builder Widgets

FutureBuilder, StreamBuilder, and LayoutBuilder

Builder widgets rebuild their children in response to async events, layout changes, or animation ticks.

Builds UI based on a Future's state: waiting, done with data, or done with error.

FutureBuilder<String>(
  future: fetchUserName(),
  builder: (context, snapshot) {
    if (snapshot.connectionState ==
        ConnectionState.waiting) {
      return CircularProgressIndicator();
    }
    if (snapshot.hasError) {
      return Text('Error: ${snapshot.error}');
    }
    return Text('Hello, ${snapshot.data}');
  },
)
FutureBuilder States