클립보드 패키지는 플러터 개발자에게 Android, iOS, macOS 및 Windows에서 텍스트, 리치 텍스트(HTML), 이미지 데이터를 지원하는 시스템 클립보드에 원활하게 액세스할 수 있도록 제공합니다. 클립보드에서 읽고 쓰는 기능을 가능하게 하여 형식이 지정된 콘텐츠나 미디어를 다루는 앱의 복사/붙여넣기 기능에 이상적입니다. 이 패키지는 플러터 생태계와 원활하게 통합되며, samuelezedi.com에서 유지 관리됩니다. 오픈소스 성격으로 인해 커뮤니티 기여와 투명성이 보장됩니다.
사용 사례
앱 간에 형식이 지정된 텍스트 복사
리치 텍스트 에디터에 HTML 콘텐츠 붙여넣기
클립보드를 통해 이미지 공유
클립보드로 복사 버튼 구현
Flutter와 네이티브 앱 간 데이터 전송
주요 기능
일반 텍스트 및 HTML 지원
이미지 데이터를 처리합니다
크로스 플랫폼 호환성
읽기/쓰기 작업을 위한 간단한 API
오픈소스, 공개 저장소
적합한 대상
풍부한 텍스트 복사가 필요한 앱
콘텐츠 에디터를 개발하는 개발자
시스템 클립보드와 데이터를 교환해야 하는 도구
크로스플랫폼 데스크톱 및 모바일 앱
고려 사항
일부 시스템에서는 플랫폼별 권한이 필요합니다
이미지 처리는 플랫폼에 따라 다를 수 있습니다
시스템 클립보드 범위로 제한
내장된 기록 관리 없음
하위 OS 클립보드 동작에 따라 다릅니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Enhanced Flutter Clipboard
A super-power clipboard package for Flutter, with text, Rich text (HTML), and image support.
✅ Error Handling: Comprehensive error handling with custom exceptions and error codes
✅ Utility Methods: Check clipboard status, size, and content type
✅ Callback Support: Success and error callbacks for operations
✅ Debug Information: Get detailed clipboard debugging info
✅ Cross-Platform: Works on Android, iOS, Web, and Windows with graceful fallbacks
✅ Null Safety: Full null safety support
✅ Memory Safe: Proper listener management with cleanup mechanisms
✅ Production Ready: Battle-tested with comprehensive error handling
Installation
Add this to your package's pubspec.yaml file:
dependencies:clipboard:^3.0.14
Platform Setup
Android
The package uses platform channels for enhanced features. No additional setup required - the package automatically falls back to Flutter's built-in Clipboard API if platform channels are unavailable.
iOS
No additional setup required. The package automatically handles platform channel registration.
Web
Fully supported with automatic fallback to browser Clipboard API.
Windows
No additional setup required. The package uses native Windows API with GDI+ for image support. Platform channels are automatically registered.
import'dart:typed_data';
import'package:flutter/services.dart';
// Copy image to clipboardfinalByteData imageData = await rootBundle.load('assets/image.png');
finalUint8List imageBytes = imageData.buffer.asUint8List();
awaitFlutterClipboard.copyImage(imageBytes);
// Paste image from clipboardfinalUint8List? pastedImage = awaitFlutterClipboard.pasteImage();
if (pastedImage != null) {
// Use the image bytes (e.g., display in Image.memory)Image.memory(pastedImage);
}
// Images are also included in pasteRichText()final data = awaitFlutterClipboard.pasteRichText();
if (data.hasImage) {
print('Clipboard contains image: ${data.imageBytes?.length} bytes');
}
The package includes comprehensive testing utilities:
// Set mock data for testingawaitFlutterClipboard.setMockData('Test data');
// Get debug information for testingMap<String, dynamic> info = awaitFlutterClipboard.getDebugInfo();
Why This Enhanced Package?
I originally built this package 4 years ago for basic clipboard functionality. Over time, I realized developers needed more advanced features:
True Rich Text Support: Native HTML clipboard support via platform channels (not just in-memory storage)
Production Ready: Graceful fallbacks ensure reliability across all platforms
Modern API: Updated to latest Dart/Flutter standards with platform channel support
This enhanced version maintains backward compatibility while adding powerful new features that modern Flutter apps need. The package now uses platform channels for true multi-format support and native clipboard monitoring, with automatic fallbacks to Flutter's built-in Clipboard API when needed.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.