Skip to main content

Errors

Captures reject with an Error whose message is one of these:

MessageSourcePlatformCause
ViewShotView is not mounted.ViewShotViewBothcapture() was called while the ViewShotView was not mounted.
Cannot capture a view with an empty size.ViewShot.captureBothThe view's width or height is zero.
Failed to read the captured image.ViewShot.captureiOSThe renderer produced no CGImage.
The capture produced no image.ViewShot.captureAndroidThe ImageReader delivered no image for the drawn frame.

On Android, an exception thrown while drawing the view rejects the promise with that exception.

try {
const image = await shot.current?.capture()
} catch (error) {
// error.message is one of the messages above
}

Fixes for the common ones are in Troubleshooting.