fetch method Null safety

Future<ResponseBody> fetch(
  1. RequestOptions options,
  2. Stream<Uint8List>? requestStream,
  3. Future? cancelFuture

We should implement this method to make real http requests.

options: The request options

requestStream The request stream, It will not be null only when http method is one of "POST","PUT","PATCH" and the request body is not empty.

We should give priority to using requestStream(not options.data) as request data. because supporting stream ensures the onSendProgress works.

cancelFuture: When cancelled the request, cancelFuture will be resolved! you can listen cancel event by it, for example:

 cancelFuture?.then((_)=>print("request cancelled!"))

cancelFuture: will be null when the request is not set CancelToken.


Future<ResponseBody> fetch(
  RequestOptions options,
  Stream<Uint8List>? requestStream,
  Future? cancelFuture,