request method
Implementation
Future<Response>? request(
{REQ reqType = REQ.POST,
required String url,
required Map<String, dynamic> params,
Function? onError,
String? contentType}) {
if (reqType == REQ.POST) {
return dio
.post(url,
queryParameters: params,
options: (contentType?.isNotEmpty ?? false)
? Options(contentType: contentType)
: Options())
.catchError(onError ?? () {});
} else if (reqType == REQ.GET) {
return dio.get(url, queryParameters: params).catchError(onError ?? () {});
} else if (reqType == REQ.DELETE) {
return dio
.delete(url, queryParameters: params)
.catchError(onError ?? () {});
} else if (reqType == REQ.PUT) {
return dio.put(url, queryParameters: params).catchError(onError ?? () {});
} else {
return dio
.post(url, queryParameters: params)
.catchError(onError ?? () {});
}
}