Errors
Captures reject with an Error whose message is one of these:
| Message | Source | Platform | Cause |
|---|---|---|---|
ViewShotView is not mounted. | ViewShotView | Both | capture() was called while the ViewShotView was not mounted. |
Cannot capture a view with an empty size. | ViewShot.capture | Both | The view's width or height is zero. |
Failed to read the captured image. | ViewShot.capture | iOS | The renderer produced no CGImage. |
The capture produced no image. | ViewShot.capture | Android | The 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.