![](/img/trans.png)
[英]My flutter iOS app hasn't been released yet. How can I know my firebase dynamic link works to open Appstore if the app isn't installed yet?
[英]File stored in app document directory always exists although it hasn't been created (Flutter)
我目前正在使用 flutter 开发一个移动应用程序,我想显示用户及其朋友的个人资料图片。 图片存储在 Firebase 存储中,但是为了尽量减少请求的数量,我想将每个图像加载一次,然后将其存储在本地。 我写了一个 function 从 Firebase 存储中获取图像并将其存储在应用程序文档目录中,但我无法弄清楚如何执行 ZC1C425268E68385D1AB5074C17A94F14 只有当本地文件不存在时。
这是我的代码的摘录
Future<File?> getProfilePic(String? uid) async { Directory appDocumentsDirectory = await getApplicationDocumentsDirectory(); String filepath = "${appDocumentsDirectory.path}/profiles/$uid.jpg"; if (await File(filepath).exists()) { return File(filepath); } else { var success = await downloadFromFirebaseAndSaveToLocal( "profilepic/$uid.jpg", filepath); if (success) { getProfilePic(uid); } } return null; }
不知何故,if 语句 (await File(filepath).exists()) 的条件始终为真。 我想这是有道理的。 我认为该文件存在于目录中但没有任何内容。
有谁知道如何检查文件是否有内容? 正常的 null 检查不起作用。
感谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.