Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 处理文件(.xlsx)作为颤振中Rest API的响应,并下载相同的文件_Flutter_Dart - Fatal编程技术网

Flutter 处理文件(.xlsx)作为颤振中Rest API的响应,并下载相同的文件

Flutter 处理文件(.xlsx)作为颤振中Rest API的响应,并下载相同的文件,flutter,dart,Flutter,Dart,在我的应用程序中,我点击了一个REST Api,当响应Api返回一个文件(.xlsx)时,如何处理颤振中的文件响应,并且我希望该文件能够下载到设备中,如何做到这一点?使用。不要忘记进行平台配置 final taskId = await FlutterDownloader.enqueue( url: 'your download link', savedDir: 'the path of directory where you want to save downloaded files',

在我的应用程序中,我点击了一个REST Api,当响应Api返回一个文件(.xlsx)时,如何处理颤振中的文件响应,并且我希望该文件能够下载到设备中,如何做到这一点?

使用。不要忘记进行平台配置

final taskId = await FlutterDownloader.enqueue(
  url: 'your download link',
  savedDir: 'the path of directory where you want to save downloaded files',
);

我希望这有帮助,如果有任何疑问,请发表评论。如果这个答案对你有帮助,请接受并投票表决

您可以使用Dio颤振软件包。 这里是详细代码


嘿,Kalpesh,谢谢你的回答,我怀疑我必须在url部分添加什么,因为我正在使用一些req参数访问一个api,我的json头将是什么,我是这样做的,最终头={'Content-Type':'application/json','token:$token};reqFormat['id']=“1”;字符串jsonBody=json.encode(reqFormat);最终编码=encoding.getByName('utf-8');http.Response-Response=wait-http.post(end_-point_-url,headers:headers,body:jsonBody,encoding:encoding,);如果结果是json响应,我会在响应中找到它。bodyDownload Url=http(s)://Server:Port/path?parameter1=value1¶meter2=value2
Future download1(Dio dio, String url, savePath) async {
    CancelToken cancelToken = CancelToken();
    try {
      await dio.download(url, savePath,
          onReceiveProgress: showDownloadProgress, cancelToken: cancelToken);
    } catch (e) {
      print(e);
    }
  }