asByteBuffer property

ByteBuffer? asByteBuffer

Implementation

ByteBuffer? get asByteBuffer {
  if (isByteBuffer) {
    return _body as ByteBuffer;
  } else if (isBytesArray) {
    var a = _body as List<int>;
    if (a is TypedData) {
      return (a as TypedData).buffer;
    } else {
      return Uint8List.fromList(a).buffer;
    }
  } else if (isString) {
    var s = _body as String;
    return s.toByteBuffer();
  } else if (isMap) {
    var s = asString!;
    return s.toByteBuffer();
  }

  return null;
}