writeBytes method

Future<void> writeBytes(
  1. Iterable<int> bytes
)

Implementation

Future<void> writeBytes(Iterable<int> bytes) {
  assert(_isOpen);

  if (bytes.isEmpty) {
    return _writeLock.synchronized(() {});
  }

  return _writeLock.synchronized(() async {
    if (!_isOpen) return;

    for (final slice in bytes.slices(_bufferSize)) {
      _writeBufferAsTypedList.setAll(0, slice);
      await PlatformInterface.instance.write(_fd, _writeBuffer, slice.length);
    }
  });
}