Prerequisites
- A working Flutter quickstart
- An initialized
NosmaiCameraPreview
Capture the processed frame
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
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 |