Streams
Basics of Streams
import 'dart:async';
void main() {
// Streams
var numberStream = NumberGenerator().stream;
numberStream.listen((data) {
print(data);
});
}
class NumberGenerator {
NumberGenerator() {
Timer.periodic(Duration(seconds: 1), (t) {
controller.sink.add(count);
count++;
});
}
var count = 1;
final controller = StreamController<int>();
Stream<int> get stream => controller.stream;
}

Stream emits an asynchronous sequence of data.
Types of Stream
There are two types of streams in dart :-


Error Handling in Stream

Manipulating Streams

Creating Streams

If you want to explore more about Streams : -
Last updated
Was this helpful?