Skip to content

Instantly share code, notes, and snippets.

@nkenna
Last active February 10, 2024 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkenna/deafddc35b49eff1c9c6a787c5fb18d8 to your computer and use it in GitHub Desktop.
Save nkenna/deafddc35b49eff1c9c6a787c5fb18d8 to your computer and use it in GitHub Desktop.
Sample of FutureBuilder for screen
// 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