title: How to cache the response of API calls in Flutter?
body: <p>I am working in Flutter App to get the items from API. I want to cache the API response for 12 hours. Every 12 hours the response will be changed. Once the 12 hours completed then I need to fetch it from Internet. I used the below code to get it from internet.</p>
  
  <pre><code>Future&lt;List&lt;Playlist&gt;&gt; fetchPlaylistByChannelId({String channelId}) async {
  Map&lt;String, String&gt; parameters = {
    'part': 'snippet,contentDetails',
    'channelId': channelId,
    'maxResults': '10',
    'key': API_KEY,
  };
  Uri uri = Uri.https(
    _baseUrl,
    '/youtube/v3/playlists',
    parameters,
  );
  Map&lt;String, String&gt; headers = {
    HttpHeaders.contentTypeHeader: 'application/json',
  };
  
  // Get Playlist details
  var response = await http.get(uri, headers: headers);
  if (response.statusCode == 200) {
    var data = json.decode(response.body);
    List&lt;dynamic&gt; playListJson = data['items'];
  
    // Fetch all play list
    List&lt;Playlist&gt; playLists = [];
    playListJson.forEach(
      (json) =&gt; playLists.add(
        Playlist.fromMap(
          json["id"],
          json["snippet"],
          json["contentDetails"],
        ),
      ),
    );
    return playLists;
  } else {
    throw json.decode(response.body)['error']['message'];
  }   }
  </code></pre>
  
  <p>Please help me out this.</p>