put static method

Future<Response> put(
  1. dynamic url, {
  2. Map<String, String>? headers,
  3. Map<String, String>? body,
  4. Encoding? encoding,
})

Implementation

static Future<Response> put(url,
    {Map<String, String>? headers,
    Map<String, String>? body,
    Encoding? encoding}) async {
  try {
    Map<String, String> merger = new Map<String, String>();

    merger.addAll({
      'Content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json',
    });

    if (headers != null) merger.addAll(headers);

    final response = await _client.put(Uri.parse(url),
        headers: merger, body: body, encoding: encoding);

    return Response.fromJSON(json.decode(response.body));
  } catch (e, trace) {
    return Response(
        result: false,
        status: 500,
        message: requestFailedMessage,
        reporting: {
          'type': 'dart',
          'filename': 'repository.dart',
          'classname': 'Repository',
          'function': 'put',
          'line': 13,
          'message': e.toString(),
          'trace': trace,
        });
  }
}