这是我的代码片段而不是 mypdf.pdf 我想从 url 获取文件名,就像在 android 应用程序开发中一样,因为我是 Flutter 的新手,我不知道任何人都可以帮助我
Future<void> downloadPDF() async {
Dio dio = Dio();
try {
var dir = await getApplicationDocumentsDirectory();
await dio.download(pdfurl, "${dir.path}/mypdf.pdf",
onProgress: (rec, total) {
setState(() {
downloading = true;
progressString = ((rec / total) * 100).toStringAsFixed(0) + "%";
});
});
} catch (e) {
print(e);
}
setState(() {
downloading = false;
progressString = "Completed";
});
print("Download completed");
}