patch<T> method

Future<T> patch<T>(
  1. String path, {
  2. dynamic body,
  3. Map<String, String>? headers,
  4. Map<String, dynamic>? queryParameters,
})

Sends an HTTP PATCH request to path with optional body and decodes the JSON response as T.

If body is not a String, it is serialized via jsonEncode.

Throws an http.ClientException on non-2xx responses.

final patched = await client.patch<Map<String, dynamic>>(
  '/tasks/123',
  body: {'completed': true},
);

Implementation

Future<T> patch<T>(
  String path, {
  dynamic body,
  Map<String, String>? headers,
  Map<String, dynamic>? queryParameters,
}) async {
  final res = await _send('PATCH', path,
      body: body, headers: headers, queryParameters: queryParameters);
  return res as T;
}