widget_screenshot_plus 0.0.7

SDKflutter
Platformandroidios

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

Pub Version License

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

list_scroll_android single_widget_android

IOS

list_scroll_ios single_widget_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

ParameterDescriptionDefault
formatOutput format (PNG/JPEG)ShotFormat.png
qualityImage quality (0-100)100
pixelRatioDevice pixel ratioDevice default
backgroundColorBackground color for the screenshotnull (transparent)
scrollControllerFor capturing scrollable contentnull
maxHeightMaximum height for scroll capture10000

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.