repaintBoundaryToImage static method

Future<ByteData> repaintBoundaryToImage(
  1. GlobalKey<State<StatefulWidget>> key, {
  2. double pixelRatio = 1.0,
})

Implementation

static Future<ByteData> repaintBoundaryToImage(GlobalKey key, {double pixelRatio = 1.0}) {
	return new Future.delayed(const Duration(milliseconds: 20), () async {
		RenderRepaintBoundary repaintBoundary = key.currentContext!.findRenderObject()! as RenderRepaintBoundary;

		ui.Image image = await repaintBoundary.toImage(pixelRatio: pixelRatio);
		ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);

		return byteData!;
	});
}