multipartRequest method

  1. @override
Future<Response> multipartRequest(
  1. Uri uri, {
  2. List<MultipartFile>? files,
  3. Map<String, String>? headers,
  4. String method = 'POST',
  5. Duration? timeout,
})
override

Implementation

@override
Future<Response> multipartRequest(
  Uri uri, {
  List<MultipartFile>? files,
  Map<String, String>? headers,
  String method = 'POST',
  Duration? timeout,
}) async {
  final request = MultipartRequest(method, uri);

  if (files != null) {
    request.files.addAll(files);
  }

  if (headers != null) {
    request.headers.addAll(headers);
  }

  return Response.fromStream(await oauthClient.send(request))
      .timeout(timeout ?? defaultTimeout)
      .then((response) {
    if (response.statusCode >= 200 && response.statusCode < 300) {
      return response;
    } else {
      return Future.error(response);
    }
  });
}