我有图像的网络 url,我需要获取 Uint8List。我怎样才能转换它?我检查类似问题的答案,但这些方法不起作用。 如何从网络图像中获取 Flutter Uint8List?
kay*_*aya 10
尝试这个:
Uint8List bytes = (await NetworkAssetBundle(Uri.parse(url)).load(url))
.buffer
.asUint8List();
Run Code Online (Sandbox Code Playgroud)
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);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4744 次 |
| 最近记录: |