putJSON<S, T> method Null safety

Future<T> putJSON<S, T>(
  1. String path,
  2. {int? statusCode,
  3. void fail(
    1. Response response
  4. Map<String, String>? headers,
  5. Map<String, dynamic>? params,
  6. JSONConverter<S, T>? convert,
  7. dynamic body,
  8. String? preview}

Handles PUT Requests that respond with JSON

path can either be a path like '/repos' or a full url. statusCode is the expected status code. If it is null, it is ignored. If the status code that the response returns is not the status code you provide then the fail function will be called with the HTTP Response.

If you don't throw an error or break out somehow, it will go into some error checking that throws exceptions when it finds a 404 or 401. If it doesn't find a general HTTP Status Code for errors, it throws an Unknown Error.

headers are HTTP Headers. If it doesn't exist, the 'Accept' and 'Authorization' headers are added. params are query string parameters. convert is a simple function that is passed this GitHub instance and a JSON object.

The future will pass the object returned from this function to the then method. The default convert function returns the input object. body is the data to send to the server. Pass in a List


Future<T> putJSON<S, T>(
  String path, {
  int? statusCode,
  void Function(http.Response response)? fail,
  Map<String, String>? headers,
  Map<String, dynamic>? params,
  JSONConverter<S, T>? convert,
  dynamic body,
  String? preview,
}) =>
      statusCode: statusCode,
      fail: fail,
      headers: headers,
      params: params,
      convert: convert,
      body: body,
      preview: preview,