我使用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
答案 0 :(得分:5)
答案 1 :(得分:1)
使用 FileImage 如下。它以文件为参数。
_image = File(path);
Container(
padding: const EdgeInsets.all(1.0),
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: FileImage(_image), fit: BoxFit.cover)),
)
答案 2 :(得分:0)
从资产加载时,我遇到此错误:
课程::使用Image.asset
代替Image.network
示例:
Image.asset( "assets/image.png")
代替
Image.network( "assets/image.png")