contentLength property

int? get contentLength

Get response Content-Length in bytes.

Returns the value of the Content-Length header as an integer, or null if the header is not present or invalid.

Example:

expect(response.contentLength, 1234);
expect(response.body.length, response.contentLength);

Returns the content length in bytes or null.

Implementation

int? get contentLength {
  final lengthHeader = header('content-length');
  return lengthHeader != null ? int.tryParse(lengthHeader) : null;
}