Skip to content

Leobuaa/clipboard_watcher

 
 

Repository files navigation

clipboard_watcher

pub version All Contributors

This plugin allows Flutter apps to watch clipboard changes.


English | 简体中文


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:

dependencies:
  clipboard_watcher: ^0.2.0

Or

dependencies:
  clipboard_watcher:
    git:
      url: https://github.com/leanflutter/clipboard_watcher.git
      ref: main

Usage

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> 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 - A convenient translation and dictionary app.

Contributors

LiJianying
LiJianying

💻
Ademar
Ademar

💻
Amritpal Singh
Amritpal Singh

💻
J-P Nurmi
J-P Nurmi

💻
Add your contributions

License

MIT

About

This plugin allows Flutter apps to watch clipboard changes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 42.8%
  • CMake 25.4%
  • Swift 8.5%
  • Dart 6.5%
  • Ruby 6.3%
  • Kotlin 5.8%
  • Other 4.7%