write method

  1. @override
Future<void> write(
  1. Uint8List bytes
)
override

Implementation

@override
Future<void> write(Uint8List bytes) async {
  final raw = _raw;
  if (raw == null) throw Exception();
  final buf = calloc<Uint8>(bytes.lengthInBytes);
  final Uint8List _buf = buf.asTypedList(bytes.lengthInBytes);
  _buf.setRange(0, bytes.lengthInBytes, bytes);
  var offset = 0;
  while (isOpen && bytes.lengthInBytes - offset > 0) {
    final count =
        _api.write(raw, buf.elementAt(offset), bytes.lengthInBytes - offset);
    if (count == -1) {
      break;
    } else {
      offset += count;
    }
  }
  calloc.free(buf);
}