dart - Flutter - 显示来自相机的本地镜像

我使用 Flutter camera plugin 生成了一个图像. 我正在尝试展示它。

我的路径如下:

/data/user/0/com.example.myapp/app_flutter/picture2.jpg

我应该如何加载它?

我试过了:

new Image.network("file:///"+imagePath)

但我得到了错误:

Another exception was thrown: Invalid argument(s): No host specified in URI file:////data/user/0/com.example.myapp/app_flutter/picture2.jpg

最佳答案

方法是使用:

new Image.file(File(imagePath))

见 stackoverflow questions

https://stackoverflow.com/questions/50377343/

相关文章:

email - 使用 Flutter 的电子邮件进行 Firebase 身份验证

dart - 在小部件或状态上保留最终字段?

ios - 关闭 Cupertino 对话 Action Flutter

dart - flutter 相机插件

flutter - Flutter 中按钮中的自定义图像

dart - 根据当前查看的页面更改 AppBar 的颜色和文本

firebase - 我可以使用 StreamBuilder 在 Firestore 中收听单个文档

flutter - Cocoapods 找不到 pod Firebase 的兼容版本

flutter - 使用谷歌地图的两个屏幕返回应用程序的问题

dart - API调用后有状态小部件的 flutter 计时问题