repaintBoundaryToImage static method
Future<ByteData>
repaintBoundaryToImage(
- GlobalKey<
State< key, {StatefulWidget> > - 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!;
});
}