title: How can I download file using flutter dio?
body: <p>I want to downlaod file using url with help of flutter <code>Dio</code>. </p>
  
  <pre><code>  final imgUrl = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf";
    var dio = Dio();
  </code></pre>
  
  <pre><code>RaisedButton.icon(
                    onPressed: (){
                      download2(dio, imgUrl, "./example/boo2.pdf");
                    },
                    icon: Icon(Icons.file_download,color: Colors.white,),
                    color: Colors.green,
                    textColor: Colors.white,
                    label: Text('Dowload Invoice')
                )
  
  
  </code></pre>
  
  <pre><code> Future download2(Dio dio, String url, String savePath) async {
      try {
        Response response = await dio.get(
          url,
          onReceiveProgress: showDownloadProgress,
          //Received data with List&lt;int&gt;
          options: Options(
              responseType: ResponseType.bytes,
              followRedirects: false,
              validateStatus: (status) { return status &lt; 500; }
              ),
        );
        print(response.headers);
        File file = File(savePath);
        var raf = file.openSync(mode: FileMode.write);
        // response.data is List&lt;int&gt; type
        raf.writeFromSync(response.data);
        await raf.close();
      } catch (e) {
        print(e);
      }
    }
  
    void showDownloadProgress(received, total) {
      if (total != -1) {
        print((received / total * 100).toStringAsFixed(0) + "%");
      }
    }
  </code></pre>
  
  <p>i am gettng this error.</p>
  
  <p>OS Error: Permission denied, errno = 13flutter</p>