getMethodCall method
dynamic
getMethodCall(
{ - required String api,
- required Function fun,
})
Implementation
getMethodCall({required String api, required Function fun}) async {
if (kDebugMode) {
print("<<>>>>>API CALL>>>>>>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n$api");
}
try {
Response response = await dio.get(api);
if (response.statusCode == 200) {
try {
fun(response.data);
} catch (e) {
if (kDebugMode) {
print("Message is: $e");
}
}
} else {
fun(failedMap);
}
} on DioException catch (e) {
if (kDebugMode) {
print("Message is: $e");
}
fun(failedMap);
}
}