Not sure, how to configure or implement Retry Policy with a delay. Currently, I am using RetryPolicy for refresh token but would like to extend its usage by handling the no internet connectivity retry and for that i am trying to capture the exception in this function shouldAttemptRetryOnException and returning true. However, this function immediately tries 3 attempts back to back without any delay. So would like to know what how can I add a delay in between or is there anything in http_interceptor to configure delays between requests.
import 'package:http_interceptor/http_interceptor.dart';
class RefreshAndRetryTokenPolicy extends RetryPolicy {
@override
int get maxRetryAttempts => 3;
@override
bool shouldAttemptRetryOnException(Exception reason) {
print('Exception in policy $reason');
//when no internet connection encountered, allow user to retry the same request
return true;
}
@override
Future<bool> shouldAttemptRetryOnResponse(ResponseData response) async {
//currently handling refresh token successfully
return true;
}
}
Not sure, how to configure or implement Retry Policy with a delay. Currently, I am using RetryPolicy for refresh token but would like to extend its usage by handling the no internet connectivity retry and for that i am trying to capture the exception in this function
shouldAttemptRetryOnExceptionand returningtrue. However, this function immediately tries 3 attempts back to back without any delay. So would like to know what how can I add a delay in between or is there anything inhttp_interceptorto configure delays between requests.