coerceByteStream static method
Coerce a stream of byte chunks that came from d4rt into a
Stream<List<int>>.
This is coerceStream for the nested case, and it is a separate method
because the erasure applies twice over: the stream is a
Stream<Object?> and each chunk is a List<Object?>. Coercing only
the stream leaves chunks that fail on use; coercing only the chunks is
not expressible through a single type parameter. Each chunk goes
through coerceList, so a chunk that is not a list of ints fails with
the same message a list parameter would produce.
Implementation
static Stream<List<int>> coerceByteStream(Object? arg, String paramName) {
final value = arg is BridgedInstance ? arg.nativeObject : arg;
if (value is Stream<List<int>>) return value;
if (value is! Stream) {
throw ArgumentD4rtException(
'Invalid parameter "$paramName": expected Stream<List<int>>, '
'got ${value.runtimeType}',
);
}
return value.map<List<int>>((chunk) => coerceList<int>(chunk, paramName));
}