captureFromWidget method
Future<Uint8List?>
captureFromWidget(
- Widget widget, {
- required ImageInfos imageInfos,
- Size? targetSize,
- OutputFormat? format,
- dynamic onImageCaptured()?,
- bool stateHistroyScreenshot = false,
- String? id,
Capture an invisible widget.
Implementation
Future<Uint8List?> captureFromWidget(
Widget widget, {
required ImageInfos imageInfos,
Size? targetSize,
OutputFormat? format,
Function(ui.Image?)? onImageCaptured,
bool stateHistroyScreenshot = false,
String? id,
}) async {
recordReadyHelper = Completer();
recorderStream.add(
SizedBox(
width: targetSize?.width,
height: targetSize?.height,
child: FittedBox(
fit: BoxFit.contain,
child: widget,
),
),
);
/// Ensure the recorder is ready
if (!recordReadyHelper.isCompleted) {
await recordReadyHelper.future;
}
ui.Image? image = await _getRenderedImage(
imageInfos: imageInfos,
useThumbnailSize: false,
widgetKey: recorderKey,
);
recorderStream.add(null);
return _capture(
image: image,
imageInfos: imageInfos,
id: id,
onImageCaptured: onImageCaptured,
stateHistroyScreenshot: stateHistroyScreenshot,
outputFormat: format,
);
}