dart_clipboard 0.3.0
dart_clipboard: ^0.3.0 copied to clipboard

A Dart package to operate the clipboard using Rust FFI. This is intended for use in desktop applications.

dart_clipboard #

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.

Installation #

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
./make_symlink.ps1

# on macOS/Linux
bash ./make_symlink.sh

or copy it to the Dart project directory.

# on Windows
./copy_lib.ps1

# on macOS/Linux
bash ./copy_lib.sh

Notes #

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

Example #

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";
  Clipboard.setContents(contents);
}

License #

dart_clipboard is under the MIT License.

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

References #

0
likes
120
pub points
1%
popularity

A Dart package to operate the clipboard using Rust FFI. This is intended for use in desktop applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

ffi, test

More

Packages that depend on dart_clipboard