Created
April 12, 2018 01:39
-
-
Save jonahwilliams/e8d71584c54d9c7c2d8dffb21f70d061 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/foundation.dart'; | |
void main() { | |
final controller = new StreamController(sync: true); | |
controller.add(2); | |
new Future.delayed(const Duration(seconds: 1)).then((_) { | |
controller.add(3); | |
}); | |
runApp(new MaterialApp(home: new StreamBuilder( | |
stream: controller.stream, | |
builder: (context, snapshot) { | |
if (snapshot.hasData) { | |
return new Text('${snapshot.data}', textDirection: TextDirection.ltr,); | |
} | |
// this is never displayed | |
return new Text('LOADING', textDirection: TextDirection.ltr,); | |
}))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment