Skip to content

Instantly share code, notes, and snippets.

@phyowaikyaw-mobiledev
Created April 6, 2026 12:12
Show Gist options
  • Select an option

  • Save phyowaikyaw-mobiledev/08aaa5447cedcbfa5b002b74f983af09 to your computer and use it in GitHub Desktop.

Select an option

Save phyowaikyaw-mobiledev/08aaa5447cedcbfa5b002b74f983af09 to your computer and use it in GitHub Desktop.
Assignment 20 - Stream with Custom StreamTransformer
import 'dart:async';
Stream<dynamic> emit() async* {
yield 1;
yield 'hello';
yield 2;
yield 'world';
yield 3;
}
class FilterInt extends StreamTransformerBase<dynamic, int> {
@override
Stream<int> bind(Stream<dynamic> stream) {
return stream.where((event) => event is int).cast<int>();
}
}
void main() async {
await for (final value in emit().transform(FilterInt())) {
print(value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment