flutter
                                
                                 flutter copied to clipboard
                                
                                    flutter copied to clipboard
                            
                            
                            
                        Flutter clipboard should support images
Use case
It would be nice to also support videos and binary data in general. But having images would already be a big help.
Proposal
I can write a plugin but such basic behavior should be part of the Flutter framework. Having it in the framework also allows integrating it with Flutter widgets like TextField.
Related issues
https://github.com/flutter/flutter/issues/30719
Hi, Any update on this feature? Are there any alternatives at the moment, for importing/exporting an image copied to the clipboard?
Thanks
same problem/question. Any update?
Yes, please, very much needed! In my use-case mostly text/html. But image/... as well.
For those interested: I got it to work on iOS through Flutter Channels:
// main.dart
class MyTextSelectionControls extends CupertinoTextSelectionControls {
// https://api.flutter.dev/flutter/widgets/TextSelectionControls/handlePaste.html
// https://flutter.dev/docs/development/platform-integration/platform-channels#step-4-add-an-ios-platform-specific-implementation
  static final channelName = 'clipboard/image';
  final methodChannel = MethodChannel(channelName);
  Function(ImageProvider) callback;
  MyTextSelectionControls(this.callback);
  @override
  Future<void> handlePaste(TextSelectionDelegate delegate) async {
    await getClipboardImage();
    final TextEditingValue value =
        delegate.textEditingValue; // Snapshot the input before using `await`.
    final ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
    if (data != null) {
      delegate.textEditingValue = TextEditingValue(
        text: value.selection.textBefore(value.text) +
            data.text +
            value.selection.textAfter(value.text),
        selection: TextSelection.collapsed(
            offset: value.selection.start + data.text.length),
      );
    }
    delegate.bringIntoView(delegate.textEditingValue.selection.extent);
    delegate.hideToolbar();
  }
  getClipboardImage() async {
    try {
      final result = await methodChannel.invokeMethod('getClipboardImage');
      ImageProvider prov = Image.memory(result).image;
      callback(prov);
    } on PlatformException catch (e) {
      print("error in getting clipboard image");
      print(e);
    }
  }
}
// AppDelegate.swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    
    let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
        let batteryChannel = FlutterMethodChannel(name: "clipboard/image",
                                                  binaryMessenger: controller.binaryMessenger)
        batteryChannel.setMethodCallHandler({
          (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
          // Note: this method is invoked on the UI thread.
            guard call.method == "getClipboardImage" else {
              result(FlutterMethodNotImplemented)
              return
            }
            self.getClipboardImage(result: result)
        })
    
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
    
    // https://flutter.dev/docs/development/platform-integration/platform-channels#step-4-add-an-ios-platform-specific-implementation
    // https://www.raywenderlich.com/2882495-your-own-image-picker-with-flutter-channels#toc-anchor-008
    private func getClipboardImage(result: FlutterResult) {
      
        let image = UIPasteboard.general.image;
        
        if (image == nil) {
            print("no image in clipboard")
            return
        }
        
        let data = image!.jpegData(compressionQuality: 0.9)
        result(data)
        
    }
    
}
Full Gist: https://gist.github.com/Krecharles/4338276a4b6763378544d276d5998408
same problem/question. Any update?
same problem/question. Any update?
Also facing same issue. Any updates?
this feature request opened at almost 2 years ago, is there any plan for it ?
It's a requirement for my current project. Hoping to see it soon.
https://pub.dev/packages/pasteboard is helpful.
issue opened 3 years go, any suggestions here ? thanks
is there any plan for it ?
need support in this issue... but no any update
need support in this issue... but no any update
Use this: sensuikan1973 commented [on 27 Jul]
https://pub.dev/packages/pasteboard is helpful.
Seems like a reasonable expectation of a modern UX development framework designed to work on modern devices that you can copy/paste to/from the OS clipboard buffer with both text AND image. How many years have we had graphical operating systems with the ability to copy and paste images? Probably close to 30 years !!
I love Flutter, but sometimes the depth on features vs the breadth of features across the supported platforms seems to be out of whack. Not sure where the focus and energy is being invested, but doesn't seem to be with much direction or planning.... anyway, I'm sure eventually it will be looked into... though after 3 years we seem to be no further advanced :-(
@gslender Flutter is also a framework that is highly driven by the community. Did you try pasteboard ? In my case, it works flawlessly.
@Eerey yep, but the support of all platforms and all features is inconsistent (eg paste of image is poorly supported).
If the excuse for poorly supporting basic platform functionality is always the communities fault then Flutter is doomed. The project team need to enroll more people and delegate more control - it's going to quickly suffocate under its own weight if they don't close these types of gaps soon.
Seems like a duplicate of https://github.com/flutter/flutter/issues/23603? Can this be closed?
any updates?
Please remember https://github.com/flutter/flutter/wiki/Issue-hygiene#do-not-add-me-too-or-same-or-is-there-an-update-comments-to-bugs
https://pub.dev/packages/pasteboard is helpful.
It is helpful but it's better if Flutter supports it officially. Currently we have to:
- Override the Ctrl/Command+V event by using ShortcutsandActionswidget
- Override the context menu of TextFieldby usingcontextMenuBuilder
- Disable the default context menu on web by using BrowserContextMenu.disableContextMenu()(which also disables the context menu in other places 🤯).
I only want to override the paste action in the Textfield without affecting the context menu in other widgets, and it seems impossible at this point.
+1, this is crucial functionality that has been lacking for years. Platform channels seem to be the only current solution, which contradicts the multi-platform nature of Flutter.