# clipboard_watcher
**Repository Path**: leanflutter/clipboard_watcher
## Basic Information
- **Project Name**: clipboard_watcher
- **Description**: 这个插件允许 Flutter 桌面应用程序观察剪贴板的变化。
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: https://pub.dev/packages/clipboard_watcher
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2022-04-21
- **Last Updated**: 2024-11-06
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# clipboard_watcher
[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url] ![][visits-count-image] [![All Contributors][all-contributors-image]](#contributors)
[pub-image]: https://img.shields.io/pub/v/clipboard_watcher.svg
[pub-url]: https://pub.dev/packages/clipboard_watcher
[discord-image]: https://img.shields.io/discord/884679008049037342.svg
[discord-url]: https://discord.gg/zPa6EZ2jqb
[visits-count-image]: https://img.shields.io/badge/dynamic/json?label=Visits%20Count&query=value&url=https://api.countapi.xyz/hit/leanflutter.clipboard_watcher/visits
[all-contributors-image]: https://img.shields.io/github/all-contributors/leanflutter/clipboard_watcher?color=ee8449&style=flat-square
This plugin allows Flutter apps to watch clipboard changes.
---
English | [简体中文](./README-ZH.md)
---
- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Usage](#usage)
- [Who's using it?](#whos-using-it)
- [Contributors](#contributors)
- [License](#license)
## Platform Support
| Platform | Support |
| -------- | :---------------------------------------------------------------------------------------------------------------- |
| Linux | ✔️ Fully supported |
| macOS | ✔️ Fully supported |
| Windows | ✔️ Fully supported |
| iOS | 14+ Needs user permission to read data copied from others apps
Old versions are fully supported out of the box |
| Android | 10+ Only works when the app is in the foreground
Old versions are fully supported out of the box |
## Quick Start
### Installation
Add this to your package's pubspec.yaml file:
```yaml
dependencies:
clipboard_watcher: ^0.2.0
```
### Usage
```dart
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State with ClipboardListener {
@override
void initState() {
clipboardWatcher.addListener(this);
// start watch
clipboardWatcher.start();
super.initState();
}
@override
void dispose() {
clipboardWatcher.removeListener(this);
// stop watch
clipboardWatcher.stop();
super.dispose();
}
@override
Widget build(BuildContext context) {
// ...
}
@override
void onClipboardChanged() async {
ClipboardData? newClipboardData = await Clipboard.getData(Clipboard.kTextPlain);
print(newClipboardData?.text ?? "");
}
}
```
> Please see the example app of this plugin for a full example.
## Who's using it?
- [Biyi](https://biyidev.com/) - A convenient translation and dictionary app.
## Contributors
## License
[MIT](./LICENSE)