# 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
这个插件允许 Flutter 应用程序观察剪贴板的变化。
---
[English](./README.md) | 简体中文
---
- [平台支持](#%E5%B9%B3%E5%8F%B0%E6%94%AF%E6%8C%81)
- [快速开始](#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)
- [安装](#%E5%AE%89%E8%A3%85)
- [用法](#%E7%94%A8%E6%B3%95)
- [谁在用使用它?](#%E8%B0%81%E5%9C%A8%E7%94%A8%E4%BD%BF%E7%94%A8%E5%AE%83)
- [贡献者](#%E8%B4%A1%E7%8C%AE%E8%80%85)
- [许可证](#%E8%AE%B8%E5%8F%AF%E8%AF%81)
## 平台支持
| 平台 | 支持 |
| ------- | :--------------------------------------------------------------------- |
| Linux | ✔️ 完全支持 |
| macOS | ✔️ 完全支持 |
| Windows | ✔️ 完全支持 |
| iOS | 14+ 需要用户权限才能读取从其他应用复制的数据
旧版本完全支持开箱即用 |
| Android | 10+ 仅当应用程序位于前台时有效
旧版本完全支持开箱即用 |
## 快速开始
### 安装
将此添加到你的软件包的 pubspec.yaml 文件:
```yaml
dependencies:
clipboard_watcher: ^0.2.1
```
### 用法
```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 ?? "");
}
}
```
> 请看这个插件的示例应用,以了解完整的例子。
## 谁在用使用它?
- [比译](https://biyidev.com/) - 一个便捷的翻译和词典应用程序。
## 贡献者
## 许可证
[MIT](./LICENSE)