write method
Implementation
Future<WroteReporter> write() async {
if (!_options.enableChunkWrite) {
var reporter = await _writeData(_binary);
await _doCallback(reporter, _binary, 1, 1);
return reporter;
}
var parts = CollectionKit.split(_binary, _options.chunkSize);
var totalTimes = parts.length;
var currentTimes = 0;
for (var part in parts) {
currentTimes += 1;
var writeData = Uint8List.fromList(part);
var reporter = await _writeData(writeData);
var control =
await _doCallback(reporter, writeData, currentTimes, totalTimes);
if (control == WriteControl.stop) {
reporter.controlExit = true;
return reporter;
}
if (!reporter.ok) {
return reporter;
}
}
return WroteReporter(true, binary: _binary, controlExit: false);
}