ApiRequest constructor
ApiRequest({
- required BuildContext context,
- required ApiCallBackListener apiCallBackListener,
- required String httpType,
- required String url,
- required String apiAction,
- Map<
String, String> ? headers, - Map<
String, String> ? body, - Encoding? encoding,
- bool? isMultiPart,
- Color? progressBarColors,
- bool? showLoader,
- Map<
String, File> ? mapOfFilesAndKey, - Function? logoutFunction,
- String? apiTimeOutMsg,
- String? errorMessage,
Implementation
ApiRequest(
{required this.context,
required this.apiCallBackListener,
required this.httpType,
required this.url,
required this.apiAction,
this.headers,
this.body,
this.encoding,
this.isMultiPart,
this.progressBarColors,
this.showLoader,
this.mapOfFilesAndKey,
this.logoutFunction,
this.apiTimeOutMsg,
this.errorMessage
}) {
print("url=="+url.toString()+"\nshowLoader=="+showLoader.toString());
if (context != null) {
CommonFile.checkInternetConnectivity().then((bool isConnected) async {
if (isConnected) {
try {
ProgressDialog.show(context,progressBarColors??Colors.black,showLoader??false);
// headers = getApiHeader(accessToken);
if (isMultiPart != null && isMultiPart==true) {
getAPIMultiRequest(url,
headers: headers,
body: body,
encoding: encoding,
mapOfFilesAndKey: mapOfFilesAndKey);
} else {
getAPIRequest(url,
headers: headers, body: body, encoding: encoding);
}
} catch (onError) {
print(onError.toString());
}
} else {
CommonFile.showToastMessage("No Internet Connection.");
}
});
}
}