flutter path_provider无法读取下载的文件



我在flutter上使用path_provider,我想构建下载文件(mp4&jpg,来自aws S3(并播放它。我成功下载并确认文件已下载。(在ios上(

但是,当使用path_provider访问文件时,出现了如下错误。

Unable to load asset: /Users/username/Library/Developer/CoreSimulator/Devices/B78BC67E-B127-4DD0-8A42-965EE645157B/data/Containers

保存方法低于

Future<File> _getFile(String filename) async {
final dir = await getApplicationDocumentsDirectory();
return File("${dir.path}/$filename");
}
final file = await _getFile("filename");
file.writeAsBytes(Bytes);

并且加载方法低于

final directory = await getApplicationDocumentsDirectory();
.
.
.
Image(image: AssetImage('${directory.path}/filename')) // /Users/username/Library/Developer/CoreSimulator/Devices/B78BC67E-B127-4DD0-8A42-965EE645157B/data/Containers/Data/Application/46EF23F5-840C-47D4-8314-B97CDEE2198C/Documents
.
.
.

实际上我需要使用FileImage而不是Asset。感谢GrahamD

最新更新