HyperCaptureExtension extension
Extension on GlobalKey to capture a widget as an image.
Attach the key to a RepaintBoundary widget (or use HyperViewer.captureKey) and call these methods to export the rendered content as an image.
Usage
final captureKey = GlobalKey();
HyperViewer(
html: '<h1>Hello World</h1>',
captureKey: captureKey,
)
// Capture PNG bytes:
final bytes = await captureKey.toPngBytes();
// Capture as ui.Image:
final image = await captureKey.toImage(pixelRatio: 2.0);
- on
Methods
-
toImage(
{double? pixelRatio}) → Future< Image> -
Available on GlobalKey<
Capture the widget as a ui.Image.State< , provided by the HyperCaptureExtension extensionStatefulWidget> > -
toPngBytes(
{double? pixelRatio}) → Future< Uint8List> -
Available on GlobalKey<
Capture the widget and encode as PNG bytes.State< , provided by the HyperCaptureExtension extensionStatefulWidget> >