smartPieces method
Implementation
Stream<String> smartPieces([int? maxPieceSize]) async* {
List<List<String>> partBuffer = [];
await for (String piece in this) {
partBuffer.add(piece.smartSplit(maxPieceSize).toList());
if (partBuffer.length > 1) {
partBuffer[1].insertAll(
0,
"${partBuffer[0].removeLast()}${partBuffer[1].removeAt(0)}"
.smartSplit(maxPieceSize)
.toList(),
);
yield* Stream.fromIterable(partBuffer.removeAt(0));
}
}
yield* Stream.fromIterable(partBuffer.expand((v) => v));
}