FutureBuilder

PHOTO EMBED

Sun Apr 17 2022 02:30:37 GMT+0000 (UTC)

Saved by @kaushalPal0812 #dart

class MyWidget extends StatelessWidget {
  @override
  Widget build(context) {
    return FutureBuilder<String>(
      future: callAsyncFetch(),
      builder: (context, AsyncSnapshot<String> snapshot) {
        if (snapshot.hasData) {
          return Text(snapshot.data);
        } else {
          return CircularProgressIndicator();
        }
      }
    );
  }
}
content_copyCOPY

How to Build Widgets with an Async Method Call

https://flutterigniter.com/build-widget-with-async-method-call/