copy_from_clipboard
A Flutter package providing easy-to-use widgets for copying text to clipboard and pasting from it, with customizable feedback and support for dynamic values.
Features
CopyToClipboardButton: Copy text to clipboard with optional custom snackbar and callbacks.PasteFromClipboardButton: Paste text from clipboard with callback handling.- Customizable UI and feedback.
- Support for static text or dynamic value builders.
Getting started
Add to your pubspec.yaml:
dependencies:
copy_from_clipboard: ^0.0.1
Usage
Copy Text
CopyToClipboardButton(
text: 'Hello World',
snackbarMessage: 'Copied to clipboard!',
onCopied: () {
print('Text copied');
},
)
Copy Dynamic Text
CopyToClipboardButton(
valueBuilder: () => 'Dynamic value: ${DateTime.now()}',
)
Paste Text
PasteFromClipboardButton(
onPasted: (pastedText) {
print('Pasted: $pastedText');
// Handle the pasted text
},
snackbarMessage: 'Pasted!',
)
Custom UI
CopyToClipboardButton(
text: 'Copy me',
child: ElevatedButton(
onPressed: null, // Handled by the widget
child: Text('Custom Copy Button'),
),
)
Additional information
For more examples, see the example/ directory. Contributions welcome!