Effects Flutter
Effects / Guides / Video recording / Flutter

Record AR-filtered video in Flutter with Nosmai Effects

Updated August 22, 2026

Start and stop processed recording from Dart, then optionally save the finalized video to the device gallery.

Prerequisites

Recording configuration

startRecording() takes no configuration arguments in this Flutter API. There is no public Dart setter for recording quality, bitrate, FPS, audio enablement, output dimensions, destination path, or maximum duration. The native recorder selects its defaults and returns a temporary MP4 path.

Capture dimensions, preview layout, and encoder settings are different things. Changing the widget's width or height is not a portable way to request a particular recording resolution. Native Android can reduce recording size on measured lower-tier devices while keeping the preview size unchanged.

Use an app-owned duration limit and stop through the same serialized start/stop flow as the record button. For custom encoding or audio mixing, implement a native output adapter or use the appropriate provider's recording features; see Off-screen rendering. Do not pass per-frame video through Dart to implement a real-time encoder.

Recording and gallery permissions follow the native platform's requirements. Check playback and audio on both Android and iOS. A live provider's microphone track is not automatically a configuration for this local recorder.

Start recording

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

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

Stop and save

final recording = await nosmai.stopRecording();

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

final saved = await nosmai.saveVideoToGallery(
  recording.videoPath!,
  name: 'nosmai-video',
);
if (saved['isSuccess'] != true) {
  throw StateError('The gallery copy could not be confirmed');
}

stopRecording returns only after the video has been finalized.

Its NosmaiRecordingResult contains success, optional videoPath, duration in seconds, fileSize in bytes, and an optional error. Check the result and handle thrown errors from starting or saving. Saving to the gallery is a separate operation; verify its result before telling the user that a persistent copy is available.

Observe recording progress

final progressSubscription = nosmai.onRecordingProgress.listen((seconds) {
  debugPrint('Recording: ${seconds.toStringAsFixed(1)} seconds');
});

Progress reports elapsed seconds, not percentage or completion. Replace the log with a mounted-checked UI update. nosmai.isRecording is the wrapper's local recording state; the finalized stop result remains authoritative. Cancel the subscription when its owner leaves:

await progressSubscription.cancel();

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

SymptomCauseFix
startRecording returns falseThe preview is not ready or recording is already activeWait for processing and guard duplicate record-button taps
videoPath is nullNative finalization failedRead recording.error and keep the screen alive until stop completes

Next steps

References

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved