A high-performance Flutter plugin for capturing native screenshots with PixelCopy support (Android 8.0+). Captures exactly what users see on screen.
- Features
- Installation
- Platform Setup
- Usage
- Permission Handling
- Example Project
- FAQ
- Troubleshooting
- Contributing
- License
- Native Performance: Uses platform-specific APIs (PixelCopy on Android)
- High Fidelity: Captures exactly what's displayed on screen
- Simple API: Single method call with path return
- Automatic Media Scanning: Screenshots appear in gallery immediately
- Thread-Safe: Background processing for large screenshots
Add to your pubspec.yaml:
dependencies:
flutter_native_screenshot_plus: ^1.0.0Then run:
flutter pub get- Add permissions to
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />- For Android 10+ compatibility, add to the
<application>tag:
android:requestLegacyExternalStorage="true"Add to ios/Runner/Info.plist:
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) saves screenshots to your photo library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) saves screenshots to your photo library</string>Basic implementation:
import 'package:flutter_native_screenshot_plus/flutter_native_screenshot_plus.dart';
// Capture and save screenshot
final path = await FlutterNativeScreenshotPlus().takeScreenshot();
if (path != null) {
// Use the file path (display preview, upload, etc.)
print('Screenshot saved at: \$path');
} else {
print('Failed to capture screenshot');
}This plugin requires these permissions but doesn't handle runtime requests. We recommend using permission_handler:
// Example permission check
final status = await [Permission.storage, Permission.photos].request();
if (status[Permission.storage]!.isGranted) {
// Proceed with screenshot
}See complete implementation in the example folder. To run:
cd example
flutter run| Platform | Location |
|---|---|
| Android | /storage/emulated/0/Android/data/<package_name>/cache |
| iOS | App's Documents directory |
- Ensure permissions are granted
- On Android, wait for UI rendering to complete:
await Future.delayed(const Duration(milliseconds: 300));Use the share_plus package:
await Share.shareXFiles([XFile(screenshotPath)]);- "File not found": Check if storage permissions are granted
- "Blank images": Add delay before capturing
- Missing permissions: Verify Info.plist entries
- Sandbox issues: Use app-specific directories
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by Sujit Chanda. Happy screenshotting! 📱💥