BytesReceivedCallback typedef Null safety

BytesReceivedCallback = void Function(int cumulative, int? total)

Signature for getting notified when chunks of bytes are received while consolidating the bytes of an HttpClientResponse into a Uint8List.

The cumulative parameter will contain the total number of bytes received thus far. If the response has been gzipped, this number will be the number of compressed bytes that have been received across the wire.

The total parameter will contain the expected total number of bytes to be received across the wire (extracted from the value of the Content-Length HTTP response header), or null if the size of the response body is not known in advance (this is common for HTTP chunked transfer encoding, which itself is common when a large amount of data is being returned to the client and the total size of the response may not be known until the request has been fully processed).

This is used in consolidateHttpClientResponseBytes.

Implementation

typedef BytesReceivedCallback = void Function(int cumulative, int? total);