How to load Image widgets from ByteData in Flutter

这一生的挚爱 提交于 2020-01-25 09:57:08

问题


The multi_image_picker: 2.4.11 plugin returns a List<Asset>, each Asset having an imageData property that is a ByteData.

How can I show these in Flutter?


回答1:


You can use the Image.memory constructor.

List<Asset> assets = ...; // use multi_image_picker to get the assets

return ListView.builder(
  padding: EdgeInsets.all(8.0),
  itemExtent: assets.length,
  itemBuilder: (BuildContext context, int index) {
    return Image.memory(assets[index].imageData.buffer.asUint8List());
  },
);


来源:https://stackoverflow.com/questions/55464761/how-to-load-image-widgets-from-bytedata-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!