snapshot method

  1. @override
Future<Image?> snapshot()
override

Current image pixels, cover-fitted to currentRect by the flight. The caller owns the image; null means no pixels are available.

Implementation

@override
Future<ui.Image?> snapshot() {
  final renderObject = boundaryKey.currentContext?.findRenderObject();
  if (renderObject is! RenderRepaintBoundary) return SynchronousFuture(null);
  try {
    return SynchronousFuture(renderObject.toImageSync(pixelRatio: 1.0));
  } catch (_) {
    // Unpainted boundaries have no layer to capture.
    return SynchronousFuture(null);
  }
}