您好,我有这个方法可以从 api 获取 pdf 并返回解码的文件,我可以在单击时显示它,但我想将其保存到设备。这是我解码pdf的方法:
Future<File> _storeFile(String bytes) async {
final filename = "${_dokument?.naziv}";
final bytes = _dokument?.bytes;
Uint8List base64Decode(String source) => base64.decode(source);
await checkDocumentFolder();
String dir = directory!.path;
//final file = File('${dir.path}/$filename');
final file = File('$dir/$filename');
//var pdfBytes = bytes?.split(",")[1];
if (!file.existsSync()) file.create();
var pdfBytes = bytes?.substring(bytes.indexOf(",") + 1);
print(pdfBytes);
await file.writeAsBytes(base64Decode(pdfBytes!), flush: true);
return file;
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,我可以以某种方式将从该方法返回的文件保存到移动设备吗?