Skip to content

Instantly share code, notes, and snippets.

@BouweCeunen
Last active July 19, 2020 11:00
Show Gist options
  • Save BouweCeunen/b783d8a9f3d09899efd6f87fbf3f0eea to your computer and use it in GitHub Desktop.
Save BouweCeunen/b783d8a9f3d09899efd6f87fbf3f0eea to your computer and use it in GitHub Desktop.
Future<String> _calculation = Future<String>.delayed(
Duration(seconds: 2),
() => 'Data Loaded',
);
Widget build(BuildContext context) {
return Container(
child: FutureBuilder<String>(
future: _calculation,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasError) {
return Center(child: Text(snapshot.error.toString()));
}
if (snapshot.hasData) {
return Center(child: Text(snapshot.data));
}
return CircularProgressIndicator();
}
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment