exportToImage method

Future<Image> exportToImage(
  1. GlobalKey<State<StatefulWidget>> boundaryKey
)

Implementation

Future<ui.Image> exportToImage(GlobalKey boundaryKey) async {
  final RenderRepaintBoundary? boundary =
      boundaryKey.currentContext?.findRenderObject()
          as RenderRepaintBoundary?;
  if (boundary == null) {
    throw Exception('Editor boundary not found');
  }
  final ui.Image image = await boundary.toImage(
    pixelRatio: ui.window.devicePixelRatio,
  );
  return image;
}