widget_screenshot_plus 0.0.7
widget_screenshot_plus: ^0.0.7 copied to clipboard
Capture Flutter widgets as images with scrollable content support. Export to PNG/JPEG with custom backgrounds. Perfect for sharing UI states or generating previews.
Widget Screenshot Plus - Flutter Package #
This package is a Fork of widget_screenshot updated to the lasted version of flutter and dart.
A Flutter package for capturing widgets as images, including scrollable content and complex layouts. Perfect for sharing app content, creating previews, or saving widget states.
Features #
- 📸 Capture any widget as an image
- 🖼️ Handle scrollable content (ListView, CustomScrollView, etc.)
- 🎨 Customize output format (PNG/JPEG) and quality
- 🖌️ Add background colors to screenshots
- 📱 Support for high DPI screens with pixel ratio control
- 🧩 Merge multiple images into one composition
Android #


IOS #


Installation #
Add to your pubspec.yaml
:
dependencies:
widget_screenshot_plus: ^latest_version
Basic Usage #
1. Wrap your widget #
WidgetShotPlus(
key: _screenshotKey,
child: YourWidget(),
)
2. Capture the screenshot #
final boundary = _screenshotKey.currentContext?.findRenderObject()
as WidgetShotPlusRenderRepaintBoundary?;
final imageBytes = await boundary?.screenshot(
format: ShotFormat.png,
quality: 100,
);
Examples #
Simple Widget Capture #
// Wrap your widget
WidgetShotPlus(
key: _screenshotKey,
child: Container(
color: Colors.blue,
child: Text('Capture me!'),
),
)
// Capture it
final imageBytes = await boundary.screenshot();
Scrollable Content #
// Use with scroll controller
final _scrollController = ScrollController();
WidgetShotPlus(
key: _screenshotKey,
child: ListView(
controller: _scrollController,
children: [...],
),
)
// Capture entire scrollable content
final imageBytes = await boundary.screenshot(
scrollController: _scrollController,
);
Save and Share #
// Save to file
final dir = await getApplicationDocumentsDirectory();
final imageFile = File('${dir.path}/screenshot.png');
await imageFile.writeAsBytes(imageBytes!);
// Share using share_plus
await Share.shareXFiles([XFile(imageFile.path)]);
Advanced Options #
Parameter | Description | Default |
---|---|---|
format |
Output format (PNG/JPEG) | ShotFormat.png |
quality |
Image quality (0-100) | 100 |
pixelRatio |
Device pixel ratio | Device default |
backgroundColor |
Background color for the screenshot | null (transparent) |
scrollController |
For capturing scrollable content | null |
maxHeight |
Maximum height for scroll capture | 10000 |
FAQ #
Q: Can I capture widgets that are not currently visible on screen?
A: Yes! The package can capture the entire widget tree regardless of visibility.
Q: How does it handle platform differences?
A: The package uses a platform interface with method channel implementation, ensuring consistent behavior across iOS and Android.
Limitations #
- Very large captures may cause memory issues (consider splitting extremely long content)
Contributing #
Contributions are welcome! Please open issues or pull requests for any bugs or feature suggestions.
License #
MIT - See LICENSE for details.