# Record processed video in Flutter

> Start and stop processed recording from Dart, then optionally save the finalized video 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/record-video/flutter/

## Prerequisites

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

## Start recording

```dart
final nosmai = NosmaiFlutter.instance;
final started = await nosmai.startRecording();

if (!started) {
  throw StateError('Recording did not start');
}
```

## Stop and save

```dart
final recording = await nosmai.stopRecording();

if (!recording.success || recording.videoPath == null) {
  throw StateError(recording.error ?? 'Recording failed');
}

await nosmai.saveVideoToGallery(
  recording.videoPath!,
  name: 'nosmai-video',
);
```

`stopRecording` returns only after the video has been finalized.

## Lifecycle rule

Stop recording before switching the camera, navigating away, or disposing the
preview. Guard the record button so a second start or stop cannot overlap the
first operation.

## Verify it worked

Record a short clip with a visible effect, wait for `stopRecording`, and play
the returned file. Confirm the gallery copy only after saving reports success.

## Common errors

| Symptom | Cause | Fix |
| --- | --- | --- |
| `startRecording` returns `false` | The preview is not ready or recording is already active | Wait for processing and guard duplicate record-button taps |
| `videoPath` is null | Native finalization failed | Read `recording.error` and keep the screen alive until stop completes |

## Next steps

- [Capture a processed photo in Flutter](/docs/effects/guides/output/capture-a-photo/flutter/)
- [Use Nosmai with Agora in Flutter](/docs/effects/integrations/agora/flutter/)

## References

- [Flutter platform guide](/docs/effects/platforms/flutter/)
- [Flutter package](https://pub.dev/packages/nosmai_effects_sdk)
