4

I searched in google for how to copy an image to clipboard in flutter but I did not find any useful information. I only found in flutter documentation this:

"ClipboardData class:

Data stored on the system clipboard.

The system clipboard can contain data of various media types. This data structure currently supports only plain text data, in the text property."

https://api.flutter.dev/flutter/services/ClipboardData-class.html

Is it impossible to copy an image to clipboard in flutter right now?

ouzari
  • 397
  • 3
  • 12
  • I am also looking for this use case. Given the lack of an answer here, and a cursory look at the code, it seems like it is not possible with the existing framework, and I cannot find a package which seems to support the clipboard with data types other than text. It is possible to create one using method channels, but is some work, I might have to try though. – Daniel Brotherston Mar 15 '21 at 20:50
  • @DanielBrotherston Any update if you got it working by a method channel – shivanshPurple May 07 '21 at 19:36

2 Answers2

1

I did not try and not sure if the answer is you looking for but you can give a try that first you can convert your image to Uint8List format with BASE64 decode and encode then copy it. for conversion you can check this. link

how-to-convert-base64-string-into-image-with-flutter

also check answers of this threat

how-to-send-image-through-post-using-json-in-flutter

Bilal Şimşek
  • 5,453
  • 2
  • 19
  • 33
1

This package allows copying images to the clipboard:

https://github.com/superlistapp/super_native_extensions/tree/main/super_clipboard

    final item = DataWriterItem();
    item.add(Formats.png(imageData));
    await ClipboardWriter.instance.write([item]);

There's some other steps to follow to get it setup in their README, but I managed to get it working.

Bill Schumacher
  • 231
  • 2
  • 6