dart - 颤振:image.file 未显示
问题描述
我用系统的照片0.2.0来获取照片,但是当我获取照片并刷新界面时,出现了空白。
代码:
PhotoPicker.pickAsset(
context: context,
// BuildContext required
/// The following are optional parameters.
themeColor: Colors.white,
// the title color and bottom color
padding: 4.0,
//...
//...
).then((List<AssetEntity> imgList) {
//
getPhotoFile(imgList);
});
获取文件到 List photoList
List<File> photoList = [];
getPhotoFile(List<AssetEntity> imgList) async {
for (int i = 0; i < imgList.length; i++) {
AssetEntity item = imgList[i];
File tempFile = await item.file;
photoList.add(tempFile);
}
setState(() {});
}
刷新用户界面
photoList.map<Widget>((File file) {
return new FutureBuilder(
future: _getLocalFile(file),
builder: (BuildContext context, AsyncSnapshot<File> snapshot) {
return snapshot.data != null ? new Image.file(snapshot.data) : new Container();
})
: new Container();
});
}.toList();
Future<File> _getLocalFile(File file) async {
return file;
}
我得到 file.path 之类的
'/private/var/mobile/Containers/Data/Application/543EEE91-BD94-4EA7-969C-A4E3320C4B93/tmp/.images/3609017ffc0170a5968fc9edbb44eb9c.jpg'
我应该怎么做才能确保显示所有图片?
解决方案
你能给出颤振医生 -v 的结果吗?
你能把你的形象包装起来吗?
用容器归档?
这是一个例子。
child: Container(
decoration: BoxDecoration(color: Colors.teal),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.file(
推荐阅读
- jquery - 切换点击最多 4 次可以正常工作,但在第 6 次点击之后效果不佳
- php - JS数组没有被传递给php文件?
- html - 如何在 ion-item 中修改 .item-native 类?
- django - Django创建图像文件的路径
- amazon-web-services - 关于检索 AWS EC2 实例作为快照
- amazon-web-services - 用于授予对 AWS 资源的访问权限的 Amazon STS 与身份池
- openlayers - 如何在打开图层图中的标记单击上设置蜘蛛视图标记?
- angular - 如何循环 .subscribe observable
- android - Flutter:如何为常见的平板电脑屏幕密度包含自定义的可绘制资产
- php - 如何通过 $_GET['NameField'] 将 php 值插入 html 标签