getMethod static method

Future<Response> getMethod({
  1. required Uri url,
  2. Map<String, String>? headers,
  3. Map<String, dynamic>? body,
})

Implementation

static Future<Response> getMethod(
    {required Uri url, Map<String, String>? headers,
      Map<String, dynamic>? body,
    }) async{
  var request = MultipartRequest('GET', url);
  if(headers != null){
    request.headers.addAll(headers);
  }
  if (body != null) {
    // Convert the body map to JSON
    var jsonBody = jsonEncode(body);

    // Set the JSON body to the request
    request.fields['_json'] = jsonBody; // You can use a custom field key if required


    // for (var entry in body.entries) {
    //   request.fields[entry.key] = entry.value.toString();
    // }
  }

  var streamedResponse = await request.send();
  var response = await Response.fromStream(streamedResponse);
  return response;
}