Skip to content

Instantly share code, notes, and snippets.

@Vanethos
Created January 13, 2020 08:19
Show Gist options
  • Save Vanethos/87d1629f7d1edde555661e866d635276 to your computer and use it in GitHub Desktop.
Save Vanethos/87d1629f7d1edde555661e866d635276 to your computer and use it in GitHub Desktop.
class SplashPage extends StatelessWidget {
final Completer<bool> completer;
SplashPage({this.completer, Key key}) : super(key : key);
@override
Widget build(BuildContext context) {
// Fetch some information from the internet.
// When finished, complete the Completer with the `true` value
// If there is an error, then
http.get('https://jsonplaceholder.typicode.com/todos/1').then((_) =>
completer.complete(true)).catchError((_) =>
completer.complete(false));
return Material(
child: Container(
color: Colors.red,
child: Center(
child: CircularProgressIndicator(),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment