imageFromWidget function
Future<ImageReference>
imageFromWidget(
- FlutterPowerPoint pres,
- Widget builder(
- Size size
- Duration delay = const Duration(seconds: 1),
- double? pixelRatio,
- BuildContext? context,
- Size? targetSize,
Implementation
Future<ImageReference> imageFromWidget(
FlutterPowerPoint pres,
Widget Function(Size size) builder, {
Duration delay = const Duration(seconds: 1),
double? pixelRatio,
BuildContext? context,
Size? targetSize,
}) async {
final ctx = pres.context as FlutterPresentationContext;
final size = targetSize ??
Size(
Util.ptToPixle(pres.layout.width),
Util.ptToPixle(pres.layout.height),
);
final bytes = await ctx.screenshotController.captureFromWidget(
builder(size),
delay: delay,
pixelRatio: pixelRatio,
context: context,
targetSize: size,
);
final image = ImageReference.fromBytes(
bytes,
name: 'widget',
description: 'image created from a widget',
);
return image;
}