CustomizedStreams adds additional capabilities to Dart Streams and StreamControllers.
CustomizedStreams provides a number of additional Subjects that help transfrom type and value of stream.
import 'package:customized_streams/customized_streams.dart';
Stream<int> _transformCountLength(String text) async* {
yield text.length;
}
void main() {
var ts =
TransformerSubject<String, int>(_transformCountLength);
ts.outputStream.listen((data) {
print("Length of " +
ts.inputValue +
" is " +
data.toString()); // Print: Length of HelloWorld is 11
}, onDone: () {
ts.dispose();
});
ts.add("Hello World");
}
import 'package:customized_streams/customized_streams.dart';
Stream<int> _transformCountLength(String text) async* {
yield text.length;
}
void main() async {
var ts = TransformerSubject<String, int>(_transformCountLength);
var inputStream1 = ts.inputStream;
inputStream1.listen((data) {
print(data); // ["Hello", "World", "Developer"]
});
ts.add("Hello");
ts.add("World");
await Future.delayed(Duration(seconds: 1));
var inputStream2 = ts.inputStream;
inputStream2.listen((data) {
print(data); // ["World", "Developer"]
}, onDone: () {
ts.dispose();
});
ts.add("Developer");
}
In order to run the flutter example, you must have Flutter installed. For installation instructions, view the online documentation.
- Open up an Android Emulator, the iOS Simulator, or connect an appropriate mobile device for debugging.
- Open up a terminal
cd
into theexample
directory- Run
flutter doctor
to ensure you have all Flutter dependencies working. - Run
flutter packages get
- Run
flutter run
Refer to the Changelog to get all release notes.