A Dart package to operate the clipboard using Rust FFI.

dart_clipboard uses the dynamic library of ippee / libclipboard crate and requires you to download or build it.
This crate uses aweinstock314 / rust-clipboard. However, the purpose of this package is not to be a wrapper for it, but to make it easily and intuitively to operate the clipboard in Dart.


1. Add package

dart pub add dart_clipboard

2. Prepare dynamic library

Select either method A or B.

A: Use the existing build files

On your Dart project directory, run the following commands.

# on Windows
curl -LJO https://github.com/ippee/libclipboard/releases/download/0.2.0/libclipboard.dll

# on macOS
curl -LJO https://github.com/ippee/libclipboard/releases/download/0.2.0/libclipboard.dylib

# on Linux
curl -LJO https://github.com/ippee/libclipboard/releases/download/0.2.0/libclipboard.so

B: Use your own built files

This way is available in the environment which can use Rust.

First, add ippee / libclipboard repository as a submodule.

git submodule add git@github.com:ippee/libclipboard.git ./tool/libclipboard/

Next, build the dynamic library with:

cd ./tool/libclipboard/
cargo build --release

Finally, make the symbolic link to the built file,

# on Windows

# on macOS/Linux
bash ./make_symlink.sh

or copy it to the Dart project directory.

# on Windows

# on macOS/Linux
bash ./copy_lib.sh


If you publish the Dart application which uses this package, put the dynamic library in the same directory with the executable.


import 'package:dart_clipboard/dart_clipboard.dart';

void main() {
  var contents;

  // Get contents of the clipboard.
  contents = Clipboard.getContents();

  // Set contents to the clipboard.
  contents = "All the world's a stage";


dart_clipboard is under the MIT License.

Note that aweinstock314 / rust-clipboard is dual-licensed under MIT and Apache2.