imageStream<T> static method

Stream<T> imageStream<T>(
  1. Uint8List data,
  2. T req,
  3. T f(
    1. List<int>
    )
)

Implementation

static Stream<T> imageStream<T>(
    Uint8List data,
    T req,
    T Function(List<int>) f,
    ) async* {
  if (data.lengthInBytes > 100 * 100000) throw 'too large';
  yield req;
  Iterator<int> it = data.iterator;
  for (var _ = 0; _ < 100; _++) {
    while (true) {
      List<int> list = List.empty(growable: true);
      for (var i = 0; i < 100000; i++) {
        if (it.moveNext()) {
          list.add(it.current);
        }
      }
      if (list.isEmpty) break;
      yield f(list);
    }
  }
}