post method
Implementation
Future<dynamic> post(String path,
{Map? body, Map<String, String>? header}) async {
var responseJson;
try {
final response = await retry(
() => http.post(
Uri.parse(api!.endpointUrl(path)),
headers: mergeMaps({
'Content-type': 'application/json',
}, (header ?? {})),
body: json.encode(body),
),
retryIf: (e) => e is SocketException || e is TimeoutException);
responseJson = _response(response);
} on SocketException {
throw FetchDataException('No Internet connection');
} on TimeoutException {
throw FetchDataException('Connection Timeout');
} catch (e) {
throw FetchDataException('Unhandled Exception : ${e.toString()}');
}
return responseJson;
}