post method

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

Implementation

Future<Response> post(url,
    {Map<String, String>? headers, body, Encoding? encoding}) async {
  try {
    final response = await http.post(url,
        headers: headers, body: body, encoding: encoding);
    if (response.statusCode == 401 &&
        json.decode(response.body)['message'] == 'Expired JWT Token') {
      throw ExpiredTokenException(response.reasonPhrase);
    } else {
      return response;
    }
  } catch (e) {
    return http.Response(e.toString(), 500);
  }
}