readAsBytes method

Future<List<int>> readAsBytes()

Reads the body content as bytes.

Implementation

Future<List<int>> readAsBytes() async {
  if (_bodyText != null) {
    return c.utf8.encode(_bodyText!);
  }
  if (_bodyBytes != null) {
    return _bodyBytes!;
  }
  if (_bodyStream != null) {
    return buffer.readAsBytes(_bodyStream as Stream<List<int>>);
  }
  if (_body != null) {
    throw StateError('Unable to convert body to bytes');
  }
  return Uint8List(0);
}