rich_clipboard 0.1.0 copy "rich_clipboard: ^0.1.0" to clipboard
rich_clipboard: ^0.1.0 copied to clipboard

discontinued
outdated

Flutter plugin for accessing rich text and other data types in the system clipboard.

rich_clipboard #

CI

A Flutter plugin providing access to additional data types in the system clipboard.

Warning: Alpha Software #

This is an alpha package. The API can and likely will go through some revisions as support is added for more platforms.

Platform Support #

macOS Windows Linux Web Android iOS
*

Unsupported Platforms #

On unsupported platforms this plugin will provide plain text only support rather than failing. This is done by transparently calling methods on Flutter's built-in Clipboard where appropriate, or returning mock empty values where no analogue exists. In these cases some data may be silently discarded, such as when attempting to write data types other than plain text to the clipboard.

Firefox #

While "the web" is currently a supported platform, support for Firefox is currently not possible due to its incomplete implementation of the Clipboard API. Due to this limitation, the plugin will degrade to plain text only mode in that browser. Unfortunately, even that does work in all cases as Flutter's built-in clipboard support is also broken due to additional restrictions placed on the Clipboard API by Firefox. You can find the relevant Flutter bug here.

Usage #

You can use static methods on the RichClipboard class to access data in the system clipboard. The API is similar to that provided by Flutter's built-in Clipboard class.

import 'package:rich_clipboard/rich_clipboard.dart';
...
final clipboardData = await RichClipboard.getData();
if (clipboardData.html != null) {
  // Do something with HTML
} else if (clipboardData.text != null) {
  // Do something with plain text
}
...

final plainText = 'Hello there';
final html = '<html><body><h1>$plainText</h1></body></html>';
await RichClipboard.setData(RichClipboardData({
  text: plainText,
  html: html,
}));