Copying data to clipboard and pasting data from clipboard is quite simple in Flutter. However, you still need to install a necessary plugin to access clipboard.
Install all of libraries below in pubspec.yaml
dependencies: flutter: sdk: flutter clipboard_manager: ^0.0.4 clipboard: ^0.1.2+8
clipboard_manager
This plugin allows developer to copy text to clipboard in both Android and iOS.
It is quite simple to save a string to clipboard.
ClipboardManager.copyToClipBoard("some text").then((result) { print('yay, text was copied'); });
The con of this library is that it doesn’t support paste from clipboard’s latest entry.
clipboard
clipboard is a flutter package that helps copy text to clipboard and paste from clipboard.
Copy to clipboard
FlutterClipboard.copy('This is an important text. I must save it to share.').then(( value ) => print('text was copied!'));
Paste the last entry in clipboard
FlutterClipboard.paste().then((value) { print(value); setState(() {}); });