simple_clipboard 1.0.0
simple_clipboard: ^1.0.0 copied to clipboard
A simple Flutter plugin for copying and pasting text to/from the system clipboard. (Text-only, minimal implementation for learning.)
import 'package:flutter/material.dart';
import 'package:simple_clipboard/simple_clipboard.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _pastedText = 'Nothing yet';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Simple Clipboard Plugin Test')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () async {
await SimpleClipboard.copy('Hello from my plugin!');
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Copied!')),
);
},
child: const Text('Copy "Hello from my plugin!"'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () async {
final text = await SimpleClipboard.paste();
setState(() {
_pastedText = text ?? 'Empty clipboard';
});
},
child: const Text('Paste from Clipboard'),
),
const SizedBox(height: 20),
Text('Pasted: $_pastedText'),
],
),
),
),
);
}
}