put static method

Future<Map<String, dynamic>> put({
  1. required String url,
  2. Map data = const {},
  3. Map<String, String> queryParams = const {},
  4. Map<String, String>? headers,
})

Implementation

static Future<Map<String,dynamic>> put({required String url, Map data=const {},Map<String, String> queryParams=const {},Map<String, String>? headers}) async {
  Map<String,dynamic> result={"status":"failure","message":"error sending request"};
  try{
    http.Response response = await http.put(
      WebServiceHelper.parseUrl(url,params: queryParams),
      body: json.encode(data),
      headers: await WebServiceHelper.getHeaders(requestHeaders: headers),
    );
    if (response.statusCode != 200 && response.statusCode != 201) {
      _debug(response.body);
      _debug(response.statusCode);
      try {
        _handleError(url: url,response: response);
      }on Exception catch(e,stack){
        _handleException(url:url,exception: e,stackTrace: stack);
      }
    }
    else{
      result=json.decode(response.body);
    }
  }
  on Exception catch(e,stack){
    _handleException(url:url,exception: e,stackTrace: stack);
  }
  return result;
}