# Capture a processed photo in Flutter

> Capture the current processed preview and optionally save the returned image bytes to the device gallery.

> For AI agents: the complete documentation index is at https://nosmai.com/llms/effects.txt

Product: Nosmai Effects
Group: guide
Source: https://nosmai.com/docs/effects/guides/output/capture-a-photo/flutter/

## Prerequisites

- A working [Flutter quickstart](/docs/effects/quickstart/flutter/)
- An initialized `NosmaiCameraPreview`

## Capture the processed frame

```dart
final nosmai = NosmaiFlutter.instance;
final photo = await nosmai.capturePhoto();

if (!photo.success || photo.imageData == null) {
  throw StateError(photo.error ?? 'Photo capture failed');
}

final bytes = photo.imageData!;
```

`imageData` contains the captured image with the active Nosmai effects.

## Save it to the gallery

```dart
final saved = await nosmai.saveImageToGallery(
  bytes,
  name: 'nosmai-photo',
);
```

Saving is optional. Request the platform photo-library permission when the host
application requires it.

## Verify it worked

Apply a visible filter, capture once, and confirm `photo.success` is `true`, the
byte list is not empty, and the saved image contains the same effect.

## Common errors

| Symptom | Cause | Fix |
| --- | --- | --- |
| `photo.success` is `false` | The native preview is not ready | Capture after `onInitialized` |
| Save fails | Gallery access is missing or denied | Add the platform usage description and request permission |

## Next steps

- [Record processed video in Flutter](/docs/effects/guides/output/record-video/flutter/)
- [Open the Flutter example](https://github.com/nosmai/nosmai_effects_sdk_flutter/tree/main/example)

## References

- [Flutter platform guide](/docs/effects/platforms/flutter/)
- [Troubleshooting](/docs/effects/troubleshooting/)
