I am new to flutter and I am using http package for network call. I want to refresh token and call the request again if the response code of the request 200. How can I acheive this using http package? I heard about dio package but it is complicated for me.
User getUser(){
final response = http.post(Uri.https(BASE_URL, '/api/user'),
headers: {'Authorization: Bearer $token'});
if(response.statusCode == 200){
return User.fromJson(jsonDecode(response.body)['user']);
}
else if(response.statusCode == 401){
//refresh token and call getUser again
}
}