screenshots method

Future<ByteData?> screenshots({
  1. ImageByteFormat? format,
  2. double pixelRatio = 1.0,
})

截屏 format 图片格式 pixelRatio 截图分辨率比例 ui.window.devicePixelRatio

Implementation

Future<ByteData?> screenshots(
    {ui.ImageByteFormat? format, double pixelRatio = 1.0}) async {
  final RenderRepaintBoundary boundary =
      currentContext!.findRenderObject() as RenderRepaintBoundary;
  final ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
  final ByteData? byteData =
      await image.toByteData(format: format ?? ui.ImageByteFormat.rawRgba);

  /// Uint8List uint8list = byteData.buffer.asUint8List();
  return byteData;
}