process method

Iterable<int> process(
  1. Iterable<int> data, {
  2. bool dontPadLastBlock = false,
})

Implementation

Iterable<int> process(Iterable<int> data, {bool dontPadLastBlock = false}) {
  final numBlocks = (data.length / blockSize).ceil();
  final out = Uint8List(numBlocks * blockSize);
  int outOffset = 0;
  for (int i = 0; i < numBlocks; i++) {
    Iterable<int> curInputBlock;
    if (i == numBlocks - 1) {
      curInputBlock = data;
    } else {
      curInputBlock = data.take(blockSize);
    }
    if (dontPadLastBlock && i == numBlocks - 1) {
      int outBlockLen = processBlock(curInputBlock, out, outOffset,
          dontPad: dontPadLastBlock);
      outOffset += outBlockLen;
    } else {
      processBlock(curInputBlock, out, outOffset);
      outOffset += blockSize;
    }
    data = data.skip(blockSize);
  }

  if (!dontPadLastBlock || outOffset == out.length) {
    return out;
  }

  return out.sublist(0, outOffset);
}