0 purchases
buffered stream
A stream implementation that queues all inputs until there is a listener.
Usage #
A simple usage example:
import 'dart:async';
import 'package:buffered_stream/buffered_stream.dart';
import 'dart:io';
void main() async {
stdin
..echoMode = false
..lineMode = false;
var periodicStream = Stream.periodic(Duration(milliseconds: 100), (i) => i);
var stream = BufferedStream<int>.from(periodicStream);
StreamSubscription<int>? sub;
stdin.listen((event) {
if (event.first == 32) {
if (sub != null) {
print('Cancelled!');
sub!.cancel();
sub = null;
} else {
print('New Stream');
sub = stream.listen((i) {
print(i.toString());
});
}
}
});
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.