title: How to Overwrite or Update Cache files in Flutter while using Path Provider
body: <p>Below Code i have created for local caching using path provider</p>
  <pre><code>String fileName=&quot;pathString.json&quot;;
  var dir=await getTemporaryDirectory();
  File file=File(dir.path+&quot;/&quot;+fileName);
  
  if(!file.existsSync()) {
          final http.Response response = await http.get(
              Uri.parse(&quot;https://*************.herokuapp.com/*********&quot;));
          file.writeAsStringSync(
              response.body, flush: true, mode: FileMode.write);
          final data = file.readAsStringSync();
          responseData = json.decode(data);
        }else{
          final data = file.readAsStringSync();
          responseData = json.decode(data);
          final http.Response response = await http.get(
              Uri.parse(&quot;https://**************.herokuapp.com/*********&quot;));
          file.writeAsStringSync(
              response.body, flush: true, mode: FileMode.write);
        }
  </code></pre>
  <p>for first time, File can be Created. But For Second time.. Once File is created, and API fetches latest response with updated data, Cache file not get overwritten.</p>
  <p>It would be great, if anyone can help on this..</p>
  <p>Thanks in Advance.</p>