Last active
July 19, 2020 11:00
-
-
Save BouweCeunen/b783d8a9f3d09899efd6f87fbf3f0eea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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