本文介绍了如何在Flutter中通过url从网络图像中获取Uint8List?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有图像的网络URL,我需要获取Uint8List.如何转换?我检查类似问题的答案,但是这些方法不起作用.如何从网络映像中获取Flutter Uint8List?/a>
I have the network url of image and I need to get Uint8List. How can I convert it?I check answers in like question, but those ways don't work.How to get a Flutter Uint8List from a Network Image?
推荐答案
Uint8List yourVar;
final DecoderCallback callback = (Uint8List bytes, {int cacheWidth, int cacheHeight}) {
yourVar = bytes.buffer.asUint8List();
return instantiateImageCodec(bytes, targetWidth: cacheWidth, targetHeight: cacheHeight);
};
ImageProvider provider = NetworkImage(yourImageUrl);
provider.obtainKey(createLocalImageConfiguration(context)).then((key) {
provider.load(key, callback);
});
这篇关于如何在Flutter中通过url从网络图像中获取Uint8List?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!