I am retrying an api call if I get 401 response but I am not Abel to call and I am facing exception following is my retry code
final client = RetryClient(
http.Client(),
retries: 1,
when: (response) {
return response.statusCode == 401 ? true : false;
},
onRetry: (req, res, retryCount) {
print('retry started');
if (retryCount == 0 && res?.statusCode == 401) {
Provider.of<Auth>(context, listen: false).restoreAccessToken();
}
},
);
in the above code I am Abel to restore new access token but I am not Abel to retry api call following is my proxy provider I Am guessing error is coming from here
ChangeNotifierProxyProvider<Auth, ApiCalls>(
create: (_) => ApiCalls(null),
update: (context, auth, previous) => ApiCalls(auth.token)),
here after a long try I got the solution following code solved the issue I had changed code in change notifier provider
ChangeNotifierProxyProvider<Auth, ApiCalls>(
create: (_) => ApiCalls(),
update: (context, auth, previous) =>
previous!..updates(auth.token!)),