baseRequest method
Future<Map<String, dynamic>?>
baseRequest(
{ - String? function,
- Map<String, dynamic>? params,
- String? url,
- String method = 'GET',
- bool autoRepeate = false,
- int autoRepeateCount = 1000,
- int maxRepeateDelay = 5,
- FutureOr<bool> retryIf(
- Exception
)?,
- FutureOr<void> onRetry(
- Exception
)?,
})
Implementation
Future<Map<String, dynamic>?> baseRequest({
final String? function,
final Map<String, dynamic>? params,
final Map<String, String?>? headers,
final String? url,
//final int timeout = 15000,
final String method = 'GET',
bool autoRepeate = false,
int autoRepeateCount = 1000,
int maxRepeateDelay = 5,
FutureOr<bool> Function(Exception)? retryIf,
FutureOr<void> Function(Exception)? onRetry,
}) async {
if (autoRepeate) {
final r = RetryOptions(
maxAttempts: autoRepeateCount,
maxDelay: Duration(seconds: maxRepeateDelay),
);
return await r.retry(
() => _baseRequest(
function: function,
params: params,
headers: headers,
url: url,
//timeout: timeout,
method: method,
),
retryIf: retryIf,
onRetry: onRetry,
);
// onRetry: (error) => _updateStatusError(error.toString()));
} else {
return await _baseRequest(
function: function,
params: params,
headers: headers,
url: url,
//timeout: timeout,
method: method,
);
}
}