Last active
February 10, 2024 11:55
-
-
Save nkenna/deafddc35b49eff1c9c6a787c5fb18d8 to your computer and use it in GitHub Desktop.
Sample of FutureBuilder for screen
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
// sample of future builder starts | |
Future<PpleData?> _futurPple = // make request here | |
setState(() {}); | |
FutureBuilder<PpleData?>( | |
future: _futurPple, | |
builder: (context, snapshot){ | |
if(snapshot.connectionState == ConnectionState.waiting) return CircularProgressIndicator.adaptive(); // any other type of loader | |
else if(snapshot.hasData) return Placeholder(); // build your screen here | |
else if(snapshot.hasError) return Placeholder(); // handle and build widget for error | |
else return Placeholder(); // handle and build any other type of error here | |
} | |
), | |
// sample of future builder ends |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment