capturePng method

  1. @override
Future<Uint8List> capturePng(
  1. GlobalKey<State<StatefulWidget>> key
)
override

The capturePng will create a png file screenshot of everything that are visually present on the device screen.

Implementation

@override
Future<Uint8List> capturePng(GlobalKey key) async {
  RenderRepaintBoundary boundary =
      key.currentContext!.findRenderObject() as RenderRepaintBoundary;
  ui.Image image = await boundary.toImage(pixelRatio: 3.0);
  ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
  return byteData!.buffer.asUint8List();
}