doPostMethod method

void doPostMethod(
  1. OnInterfaceCallbackListener listener,
  2. Map<String, dynamic> passParaMap,
  3. String? apiName,
  4. String? apiNamePageRef, [
  5. String? previousCancelled,
])

Implementation

void doPostMethod(OnInterfaceCallbackListener listener, Map<String, dynamic> passParaMap,
    String? apiName, String? apiNamePageRef, [String? previousCancelled]) async {

  if (previousCancelled == 'CANCELLED') {
    currentCall?.cancel();
  }

  currentCall = CancelToken();

  try {
    final response = await dio.post(
      apiName ?? '',
      data: passParaMap,
      cancelToken: currentCall,
    );
    _handleResponse(response, listener, apiNamePageRef);
  } on DioException catch (e) {
    if (CancelToken.isCancel(e)) {
      return;
    }
    _handleDioError(e, listener, apiNamePageRef);
  } catch (e) {
    listener.onFetchComplete(700, 'ERROR', apiNamePageRef);
  }
}