ademar111190 / clipboard_watcher

This plugin allows Flutter desktop apps to watch clipboard changes.

Home Page:https://pub.dev/packages/clipboard_watcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clipboard_watcher

pub version

This plugin allows Flutter desktop apps to watch clipboard changes.


English | 简体中文


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  clipboard_watcher: ^0.1.3

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.

License

MIT

About

This plugin allows Flutter desktop apps to watch clipboard changes.

https://pub.dev/packages/clipboard_watcher

License:MIT License


Languages

Language:C++ 50.0%Language:CMake 29.7%Language:Dart 7.6%Language:C 4.5%Language:Swift 4.5%Language:Ruby 3.6%