doPostMultipart method
void
doPostMultipart()
Implementation
void doPostMultipart(OnInterfaceCallbackListener listener, Map<String, dynamic> passParaMap,
List<File> fileList, String filesKeyName, String? apiName, String? apiNamePageRef) async {
final formDataMap = <String, dynamic>{...passParaMap};
for (var file in fileList) {
formDataMap[filesKeyName] = await MultipartFile.fromFile(
file.path,
filename: file.path.split('/').last,
);
}
final formData = FormData.fromMap(formDataMap);
try {
final response = await dio.post(
apiName ?? '',
data: formData,
);
listener.onFetchProgress(response.statusCode ?? 200, response.data, apiNamePageRef);
listener.onFetchComplete(response.statusCode ?? 200, 'API_RESPONSE', apiNamePageRef);
} on DioException {
listener.onFetchComplete(700, 'ERROR', apiNamePageRef);
} catch (e) {
listener.onFetchComplete(700, 'ERROR', apiNamePageRef);
}
}