问题
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