Flutter: convert bitmap (e.g. screenshot) from clipboard to base64 string

Issue

This is my current requirement:
A) The screenshot/bitmap in my clipboard must be pasted into the app (Platform: primarily Windows, but must run on all other platforms aswell: Android/iOS/Linux/MacOS/Web)

I found out that Flutter does not support anything else than plain text from the clipboard and a request for image/binary extraction is requested by the community.

That’s a bummer, but then I remembered that Flutter supports ffi:

Flutter mobile can use the dart:ffi library to call native C APIs. FFI stands for foreign function interface. Other terms for similar functionality include native interface and language bindings.

That means I can write a custom or already existing C/C++ program to handle that use case and send it to flutter. However, it seems that C/C++ programs are not guaranteed to run everywhere (Android/iOS/Linux/Windows/MacOS/Web).

So, well, my conclusion is that if I want to fulfill that requirement, I basically need to write a C/C++ program for every platform.

That sounds troublesome, isn’t there anything like a standardized method on all platforms to get dynamic data out of the clipboard? So that my Flutter application handles the logic?

Solution

There’s a new package for this:
https://pub.dev/packages/pasteboard

Answered By – Marwin Lebensky

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *