Created
April 27, 2022 02:46
-
-
Save felipecastrosales/d5e48bff7f815979a3d267d36ea5d60f to your computer and use it in GitHub Desktop.
Streams Data
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() { | |
final incremento = Stream<int>.periodic( | |
Duration(seconds: 3), | |
(index) => index + 1, | |
).take(10); | |
final multi = Stream<int>.multi((controller) { | |
int numero = 1000; | |
Timer.periodic( | |
Duration(seconds: 3), | |
(_) { | |
controller.add(numero++); | |
}); | |
}); | |
incremento.listen((value) { | |
print(value); | |
}); | |
multi.listen((value) { | |
print(value); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment