Created
February 11, 2021 23:26
-
-
Save douglasiacovelli/82f51788ee1dc8129c8d8cf217ad2187 to your computer and use it in GitHub Desktop.
Exemplo stream
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'; | |
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