title: Flutter: How to Refresh token when token expires during http call?
body: <p>I am new to flutter and I am using <a href="https://pub.dev/packages/http" rel="noreferrer">http</a> 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 <a href="https://pub.dev/packages/dio" rel="noreferrer">dio</a> package but it is complicated for me.</p>
  <pre><code>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     
      }
  
  }
  </code></pre>