Clipboard Packages

A clipboard is one of the most important tools for a mobile phone user. A clipboard is a place where you can store information that you need quick access to or from. You can use those items to copy and paste them into a word processor, mail, chat program, or other function.

clipboard

This is Flutter package for copying text to the clipboard and pasting from it.

FlutterClipboard.copy('hello flutter friends').then(( value ) => print('copied'));
FlutterClipboard.paste().then((value) {
    // Do what ever you want with the value.
    setState(() {
      field.text = value;
      pasteValue = value;
    });
  });

clipboard_monitor

Clipboard monitoring with the Flutter plugin for Android and iOS. When the app isn’t running, clipboard monitoring won’t work. Additionally, when an app isn’t in focus on Android 10 (API level 29) and above, access to the clipboard is restricted.

import 'package:clipboard_monitor/clipboard_monitor.dart';

void startClipboardMonitor()  {
    ClipboardMonitor.registerCallback(onClipboardText);
}

void stopClipboardMonitor()  {
    ClipboardMonitor.unregisterCallback(onClipboardText);
}

void onClipboardText(String text) {
    print("clipboard changed: $text");
}

void stopAllClipboardMonitoring() {
    ClipboardMonitor.unregisterAllCallbacks();
}

clipboard_manager

clipboard_manager is another Flutter plugin to copy text to the clipboard.

ClipboardManager.copyToClipBoard("your text to copy").then((result) {
                        final snackBar = SnackBar(
                          content: Text('Copied to Clipboard'),
                          action: SnackBarAction(
                            label: 'Undo',
                            onPressed: () {},
                          ),
                        );
                        Scaffold.of(context).showSnackBar(snackBar);
                      });