asByteArray property

List<int>? get asByteArray

Implementation

List<int>? get asByteArray {
  final body = _body;

  if (body is ByteBuffer) {
    return body.asUint8List();
  } else if (body is List<int>) {
    return body.toUint8List();
  } else if (body is String) {
    return body.toUint8List(encoding: mimeType?.preferredStringEncoding);
  } else if (isMap) {
    return asString!.toUint8List();
  }

  return null;
}