6

I would like to copy a Text to Clipboard in a Dart console App.

There is this plugin clipboard_manager but it is specific to flutter. Is there any way to do this in pure Dart?

alexpfx
  • 6,412
  • 12
  • 52
  • 88

2 Answers2

4

The clippy dart package provides clipboard access for dart. It uses different mechanisms depending on whether you're on Linux, Mac, and Windows, but provides a simple dart API to copy and also to listen to pastes.

You might look at the server example script, which works for a console application too.

spenster
  • 548
  • 3
  • 9
0

You can do it by importing import 'package:flutter/services.dart'; and then by using the following snippet Clipboard.setData(ClipboardData(text: 'ToTheMoon123456')); **No package required!

Kyoto
  • 308
  • 4
  • 4