简体   繁体   中英

How to convert uint8List to image in flutter web

I want to take a screenshot of any widget and then share it to WhatsApp or any other app. But from the screenshot widget, I get uint8List type of image but I want to convert it into image type and then Share it with Flutter_Share plugin, so I have to convert it into Image. How to do that?

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);
                    });

Here I am trying to convert it to imagePath but I got "FormatException: Unexpected extension byte (at offset 0)" this type of error, Also I have tried,

File img = File.fromRawPath(imageFile!);

but still, I got an error.

You can use Image.memory

Image.memory(listHere);

https://api.flutter.dev/flutter/widgets/Image/Image.memory.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM