Skip to content

Instantly share code, notes, and snippets.

@douglasiacovelli
Created February 11, 2021 23:26
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 douglasiacovelli/82f51788ee1dc8129c8d8cf217ad2187 to your computer and use it in GitHub Desktop.
Save douglasiacovelli/82f51788ee1dc8129c8d8cf217ad2187 to your computer and use it in GitHub Desktop.
Exemplo stream
import 'dart:async';
void main() {
escutarDeepLinks().listen((e) {
print(e);
}, onError: (error) {
print('deu erro vei. $error');
});
}
Stream escutarDeepLinks() {
final controller = StreamController<String>();
controller.add("codando");
controller.add("tv");
Future.delayed(Duration(seconds: 1), () {
controller.add("emitindo depois de 1s");
});
Future.delayed(Duration(milliseconds: 1500), () {
controller.addError(Exception('aqui :('));
});
return controller.stream;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment