Last active
July 19, 2020 11:00
-
-
Save BouweCeunen/e07b638990cf073e87a2bc1b01c230ab 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
StreamController<String> _accountController = new StreamController(); | |
@override | |
void initState() { | |
super.initState(); | |
Future<void>.delayed( | |
Duration(seconds: 2), | |
() => _accountController.add('Data Loaded'), | |
); | |
} | |
Widget build(BuildContext context) { | |
return Container( | |
child: StreamBuilder<String>( | |
stream: _accountController.stream, | |
builder: (context, 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