post function

dynamic post(
  1. String url,
  2. dynamic data,
  3. Map<String, String> headers
)

Implementation

post(String url, dynamic data, Map<String, String> headers) async {
  try {
    var res = await http.post(Uri.parse(url), body: data, headers: headers);
    if (res.statusCode == 200) {
      return res.body;
    } else if (res.statusCode == 404) {
      throw NotFoundError("App not found(404).");
    } else {
      throw ExtraHTTPError(
          "App not found. Status code ${res.statusCode} returned.");
    }
  } catch (e) {
    rethrow;
  }
}