- Start/stop recording
- Query current recording state
- Control FPS
- Reduce output resolution with
resolutionDivisor
| Platform | Backend | Output |
|---|---|---|
| macOS | NSView (Flutter view) frame capture + AVAssetWriter (H.264) | .mp4 |
| Windows | GDI capture of Flutter native view handle + Media Foundation (H.264) | .mp4 |
| Linux | GTK/GDK capture of FlView widget (fallback: root window) + internal AVI writer |
.avi |
dependencies:
recaster: ^0.1.1flutter pub getimport 'package:recaster/recaster.dart';Future<void> startRecording({
required String outputPath,
int fps = 30,
int resolutionDivisor = 1,
});
Future<String?> stopRecording();
Future<bool> isRecording();outputPath: target file pathfps: capture rate, typical range15..60resolutionDivisor:1= original window size2= half width/height3= one-third width/height
import 'package:recaster/recaster.dart';
final recaster = Recaster();
await recaster.startRecording(
outputPath: '/tmp/recording.mp4', // use .avi on Linux
fps: 30,
resolutionDivisor: 2,
);
final recording = await recaster.isRecording();
final savedPath = await recaster.stopRecording();- Recording target is Flutter view content on all desktop platforms.
startRecordingvalidates output path before capture starts.- Always call
stopRecording()to finalize and flush the output file.
- Capture source: Flutter view via
NSViewframe capture. - Output format:
.mp4(H.264, viaAVAssetWriter). - If app sandbox is enabled, writing to arbitrary paths may be restricted by entitlements.
- Capture source: Flutter native view handle via GDI.
- Output format:
.mp4(H.264, via Media Foundation).
- Capture source:
FlViewwidget via GTK/GDK (root windowfallback). - Output format:
.avi(internal AVI writer). - AVI output is uncompressed and can be large.
startRecording can return clear platform errors for invalid output paths:
invalid_output_pathdirectory_create_failedpath_not_writable
Use these codes to handle invalid output path configuration in your app.
- Always pass an absolute
outputPath. - Create unique output file names to avoid overwriting previous recordings.
- Keep
resolutionDivisor > 1for long runs to reduce size. - Always call
stopRecording()to finalize the output file.
stop_failedon macOS often means permission/path issues.- If file is missing after stop, verify:
- final path exists
- process has write access
- correct extension per platform
