![](/img/trans.png)
[英]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.