asyncRequestString method

Future<String> asyncRequestString({
  1. required Retrofit retrofit,
  2. Map<String, String>? headers,
  3. Map<String, dynamic>? params,
  4. OnResponseStringErrorCall? errorCall,
  5. OnResponseCompleteCall? completeCall,
})

Implementation

Future<String> asyncRequestString(
    {required Retrofit retrofit,
    Map<String, String>? headers,
    Map<String, dynamic>? params,
    OnResponseStringErrorCall? errorCall,
    OnResponseCompleteCall? completeCall}) {
  String requestId = Uuid().v4().toString();
  if (completeCall != null) {
    _requestActMap[requestId] = completeCall;
  }
  var responseInterceptor = _getResponseInterceptor();
  _syncMap[requestId] = new Completer<String>();
  _request(
    retrofit: retrofit,
    headers: headers,
    params: params,
    requestId: requestId,
    responseCall: _InternalStringCall(requestId, (String requestId, String responseData) {
      var completer = _syncMap[requestId] as Completer<String>;
      completer.complete(Future.value(responseData));
    }, (String requestId, String message, String responseData) {
      var completer = _syncMap[requestId] as Completer<String>;
      completer.complete(Future.value(""));
      if (errorCall != null) {
        errorCall(requestId, message, responseData);
      }
    }, (String requestId) {
      _finishCall(requestId);
      if (completeCall != null) {
        completeCall(requestId);
      }
    }, responseInterceptor),
    enableCache: true,
  );
  var completer = _syncMap[requestId] as Completer<String>;
  return completer.future;
}