[英]I am trying to load image from memory And my method is give Future<Uint8List> but Image.memory want Uint8List in flutter
[英]How to convert uint8List to image in flutter web
我想截取任何小部件的屏幕截图,然后将其分享到 WhatsApp 或任何其他应用程序。 但是从屏幕截图小部件中,我得到了 uint8List 类型的图像,但我想将其转换为图像类型,然后与 Flutter_Share 插件共享,所以我必须将其转换为图像。 怎么做?
controller
.capture(delay: Duration(milliseconds: 10))
.then((capturedImage) async {
final imagePath = await File('/image.png').create();
await imagePath.writeAsBytes(capturedImage!);
await Share.shareFiles([imagePath.path]);
}).catchError((onError) {
print(onError);
});
在这里我试图将它转换为 imagePath 但我得到了“FormatException:意外的扩展字节(在偏移量 0)”这种类型的错误,我也试过了,
File img = File.fromRawPath(imageFile!);
但是,我仍然有一个错误。
您可以使用 Image.memory
Image.memory(listHere);
https://api.flutter.dev/flutter/widgets/Image/Image.memory.ZFC35FDC70D8222C7A
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.