apiCall static method

Future apiCall(
  1. Uri url,
  2. String body,
  3. BuildContext context
)

Implementation

static Future<dynamic> apiCall(
    Uri url, String body, BuildContext context) async {
  return http
      .post(url, body: body, headers: StringUtils.GetApiHeaders())
      .then((http.Response response) {
    Map<String, dynamic> map = json.decode(response.body);
    final int statusCode = response.statusCode;
    if (statusCode < 200 || statusCode > 400) {
      // CommonUtils.showToast(map[StringUtils.MESSAGE], Colors.red);
      Navigator.pop(context);
      throw Exception("Error while fetching data");
    }
    return map;
  });
}