captureAsUiImage method

Future<Image> captureAsUiImage({
  1. double pixelRatio = 1,
  2. Duration delay = const Duration(milliseconds: 20),
})

Captures a ui.Image. delay is to avoid a bug, you do not need to send it

Implementation

Future<ui.Image> captureAsUiImage(
    {double pixelRatio = 1,
    Duration delay = const Duration(milliseconds: 20)}) async {
  return Future.delayed(delay, () async {
    try {
      final boundary = _getRenderRepaintBoundary();
      return await boundary.toImage(pixelRatio: pixelRatio);
    } on Exception {
      throw (Exception);
    }
  });
}