Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andresaraujo/clippy
Access system clipboard in Dart (Server&Browser)
https://github.com/andresaraujo/clippy
clipboard dart dartlang
Last synced: 11 days ago
JSON representation
Access system clipboard in Dart (Server&Browser)
- Host: GitHub
- URL: https://github.com/andresaraujo/clippy
- Owner: andresaraujo
- License: bsd-3-clause
- Created: 2017-07-09T01:23:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-11T07:31:57.000Z (over 2 years ago)
- Last Synced: 2024-10-13T08:44:30.011Z (27 days ago)
- Topics: clipboard, dart, dartlang
- Language: Dart
- Homepage:
- Size: 26.4 KB
- Stars: 22
- Watchers: 2
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
_**Clippy —** Access system clipboard in Dart (Server & Browser)_
[![Pub](https://img.shields.io/pub/v/clippy.svg?style=flat-square)](https://pub.dartlang.org/packages/clippy)
[![Build Status](https://travis-ci.org/andresaraujo/clippy.svg?branch=master)](https://travis-ci.org/andresaraujo/clippy)
[![Build status](https://ci.appveyor.com/api/projects/status/ufiu8o0wvugr149b?svg=true)](https://ci.appveyor.com/project/andresaraujo/clippy)A library to access the clipboard (copy/paste) for server and browser
### Install
Add `clippy` to dependencies/dev_dependencies in in your pubspec.yaml
### Usage
#### Server
In the server Clippy supports writing and reading from the clipboard. It uses system tools for this:
- On linux uses `xsel` (Install if needed)
- On Mac uses `pbcopy`/`pbpaste`
- On windows it embeds a copy/paste tool [win-clipboard](https://github.com/sindresorhus/win-clipboard)```dart
import 'package:clippy/server.dart' as clippy;main() async {
// Write to clipboard
await clippy.write('https://github.com/andresaraujo/clippy');
// Read from clipboard
final clipboard = await clippy.read();
}
```See [example/server](/example/server)
#### Browser
In the browser Clippy supports writing and listening to paste events.
```dart
import 'package:clippy/browser.dart' as clippy;main() async {
// Write a string to clipboard
await clippy.write('https://github.com/andresaraujo/clippy');
// Write text from an element to clipboard
await clippy.write(element);
// Write current selection to clipboard
await clippy.write();
// Listen to paste event
clippy.onPaste.listen((text) => print('OnPaste: $text'));
}
```See [example/web](/example/web)