alpha_clipboard 0.1.0
alpha_clipboard: ^0.1.0 copied to clipboard
A feature-rich clipboard management package for Flutter with customizable UI, history tracking, and persistent storage.
AlphaClipboard #
A feature-rich clipboard management package for Flutter applications that provides enhanced clipboard functionality beyond the basic system clipboard.
Features #
- ๐ Enhanced Clipboard Operations: Copy and paste text with improved reliability
- ๐ Clipboard History: Track and access previously copied texts
- ๐พ Persistent Storage: Automatically save clipboard history between app sessions
- ๐จ Customizable Theming: Style the clipboard widget to match your app's design
- ๐ Light/Dark Theme Support: Pre-configured themes for both modes
- ๐งฉ Ready-to-use Widget: Flexible clipboard widget with full customization options
- ๐งช Testing Support: Properly handles clipboard operations in test environments
Installation #
Add this to your pubspec.yaml
:
dependencies:
alpha_clipboard: ^0.1.0
Then run:
flutter pub get
Getting Started #
Initialize the clipboard at the start of your app:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize with auto-save enabled and history capacity
await AlphaClipboard.initialize(
autoSave: true,
maxHistoryItems: 50,
);
runApp(MyApp());
}
Basic Usage #
Copy and Paste #
// Copy text to clipboard
await AlphaClipboard.copyText("Hello World!");
// Paste text from clipboard
String? text = await AlphaClipboard.pasteText();
Using the Clipboard Widget #
AlphaClipboard.clipboardWidget(
onCopy: (text) {
print('Copied: $text');
},
onPaste: (text) {
if (text != null) {
print('Pasted: $text');
}
},
showHistory: true,
onHistoryItemSelected: (text) {
print('Selected from history: $text');
},
)
Clipboard History Management #
// Get all history items
List<String> history = AlphaClipboard.getHistory();
// Clear history
await AlphaClipboard.clearHistory();
// Manually save current history
await AlphaClipboard.saveHistory();
// Restore saved history
await AlphaClipboard.restoreHistory();
Advanced Customization #
Custom Theme #
final myTheme = ClipboardThemeData(
backgroundColor: Colors.blue[50],
buttonColor: Colors.indigo,
textStyle: TextStyle(color: Colors.black87),
borderRadius: BorderRadius.circular(12.0),
elevation: 4.0,
padding: EdgeInsets.all(20.0),
);
AlphaClipboard.clipboardWidget(
onCopy: (text) {},
onPaste: (text) {},
theme: myTheme,
)
Using Preset Themes #
// Light theme
final lightTheme = ClipboardThemeData.light();
// Dark theme
final darkTheme = ClipboardThemeData.dark();
// Modify preset theme
final customDarkTheme = ClipboardThemeData.dark().copyWith(
buttonColor: Colors.purple,
elevation: 8.0,
);
Demo App #
The package includes a complete example app demonstrating all features:
cd example
flutter run
Implementation Details #
AlphaClipboard uses a combination of:
- Flutter's
Clipboard
API for system clipboard access SharedPreferences
for persistent storage of clipboard history- Custom widgets and themes for UI representation
Testing #
The package properly handles clipboard operations in test environments by maintaining a local reference to the last copied text, making it testable without mocking the system clipboard.
Contributions #
Contributions are welcome! If you have ideas for improvements or found a bug, please open an issue or submit a pull request.
License #
This project is licensed under the MIT License with the following usage conditions:
- Free for up to 100,000 package downloads
- $1 per month license fee for use beyond 100,000 downloads
See the LICENSE file for details.
About #
Developed and maintained by Alpha Kraft.
For inquiries, please contact: alphakraft.customer@gmail.com