clippy 1.0.0
Clippy — Access system clipboard in Dart (Server & Browser)
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
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
Browser #
In the browser Clippy supports writing and listening to paste events.
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
Changelog #
0.2.0 #
copy
now returns aFuture<bool>
- Better error handling
0.1.0 #
- Initial version, works on Linux, Osx, Windows and Browser
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
clippy: ^1.0.0
2. Install it
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:clippy/browser.dart';
import 'package:clippy/server.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
85
|
Health:
Code health derived from static analysis.
[more]
|
97
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
58
|
Overall:
Weighted score of the above.
[more]
|
83
|
We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
Platforms
Detected platforms: web
Platform components identified in package:
html
,io
.
Health issues and suggestions
Document public APIs. (-1 points)
7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
Fix lib/server.dart
. (-1.49 points)
Analysis of lib/server.dart
reported 3 hints:
line 9 col 12: Unnecessary new keyword.
line 11 col 12: Unnecessary new keyword.
line 13 col 12: Unnecessary new keyword.
Fix lib/browser.dart
. (-1 points)
Analysis of lib/browser.dart
reported 2 hints:
line 5 col 19: Unnecessary new keyword.
line 28 col 20: Unnecessary new keyword.
Format lib/src/server.dart
.
Run dartfmt
to format lib/src/server.dart
.
Maintenance suggestions
Package is getting outdated. (-32.60 points)
The package was last published 69 weeks ago.
The package description is too short. (-9 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Maintain an example.
None of the files in the package's example/
directory matches known example patterns.
Common filename patterns include main.dart
, example.dart
, and clippy.dart
. Packages with multiple examples should provide example/README.md
.
For more information see the pub package layout conventions.