fetch method
Future<ResponseBody>
fetch(
- RequestOptions options,
- Stream<
Uint8List> ? requestStream, - Future<
void> ? cancelFuture
override
Implement this method to make real HTTP requests.
options
are the request options.
requestStream
is the request stream. It will not be null only when
the request body is not empty.
Use requestStream
if your code rely on RequestOptions.onSendProgress.
cancelFuture
corresponds to CancelToken handling.
When the request is canceled, cancelFuture
will be resolved.
To await if a request has been canceled:
cancelFuture?.then((_) => print('request cancelled!'));
Implementation
@override
Future<ResponseBody> fetch(
RequestOptions options,
Stream<Uint8List>? requestStream,
Future<void>? cancelFuture,
) async {
if (_closed) {
throw StateError(
"Can't establish connection after the adapter was closed.",
);
}
return _fetch(options, requestStream, cancelFuture);
}