我正在使用 flutter_webview_plugin 包来显示网页。在网页上,我们有一个下载文件的功能。下载文件的逻辑类似于以下代码
filename = "my-file.txt"
content = 'any string generated by django'
response = HttpResponse(content, content_type='text/plain')
response['Content-Disposition'] = 'attachment;filename={0}'.format(filename)
print(response)
return response
Run Code Online (Sandbox Code Playgroud)
直接在浏览器中调用时工作正常,但在 Flutter Webview 中则没有效果。是否需要手动执行任何操作来处理它?即使我也愿意更改套餐。我也尝试了 flutter_inappwebview 但没有区别。我不想启动任何浏览器的 URL,我只想直接从应用程序下载。可以这样做吗?