T, S> class
Filters a sequence so that only events of a given type pass
In order to capture the Type correctly, it needs to be wrapped in a TypeToken as the generic parameter.
Given the way Dart generics work, one cannot simply use the
is T /
checks and castings within
OfTypeStreamTransformer itself. Therefore, the
TypeToken class was introduced to capture the type of class you'd
ofType to filter down to.
new Stream.fromIterable([1, "hi"]) .ofType(new TypeToken<String>) .listen(print); // prints "hi"
As a shortcut, you can use some pre-defined constants to write the above in the following way:
new Stream.fromIterable([1, "hi"]) .transform(new OfTypeStreamTransformer(kString)) .listen(print); // prints "hi"
If you'd like to create your own shortcuts like the example above, simply create a constant:
const TypeToken<Map<Int, String>> kMapIntString = const TypeToken<Map<Int, String>>();
Stream< T>stream) → Stream< S>
Transforms the provided
RS, RT>( ) → StreamTransformer< RS, RT>
StreamTransformer<RS, RT>view of this stream transformer. [...]inherited
Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
) → String
Returns a string representation of this object.