microphone_flutter library
Flutter integration for the microphone_dart package.
This package contributes the native microphone library to your Flutter app
(built automatically via cargokit) and re-exports the full
microphone_dart API. In most cases you only need the re-exported
Microphone entry point:
import 'package:microphone_flutter/microphone_flutter.dart';
await MicrophoneFlutter.ensureInitialized();
if (await Microphone.requestPermission()) {
final recording = await Microphone.record();
// ... later ...
final wav = await recording.stop();
}
Platform permissions
The microphone is a protected resource; your app must declare it:
- macOS / iOS: add
NSMicrophoneUsageDescriptionto the app'sInfo.plist(a short reason shown in the system prompt). On macOS also enable the "Audio Input" capability /com.apple.security.device.audio-inputentitlement for sandboxed apps. - Android: add
<uses-permission android:name="android.permission.RECORD_AUDIO"/>toAndroidManifest.xml.
The OS shows its permission prompt the first time capture starts. The web backend prompts via getUserMedia.
Classes
- AudioLevel
- A loudness reading of a chunk of captured audio.
- CaptureBackend
- A pluggable provider of microphone capture for a given platform/technique.
- CaptureDevice
- An input device the microphone can capture from.
- CaptureFormat
- Describes the audio a recording should capture.
- Microphone
- Entry point for recording audio.
- MicrophoneFlutter
-
Flutter-side conveniences over the
microphone_dartregistry. - Recording
- A handle to a single in-progress or finished recording.
- SilentBackend
- A backend that captures silence.
- SilentRecording
- The Recording returned by SilentBackend: a timer that emits zeroed PCM.
Enums
- RecordingState
- Lifecycle states of a Recording.
- SampleFormat
- The sample encoding captured frames use.
Extensions
- RecordingLevels on Recording
- Level-metering conveniences over a Recording.
- SampleFormatSize on SampleFormat
- Bytes per sample for a SampleFormat.
Functions
-
wavFromPcm(
Uint8List pcm, CaptureFormat format) → Uint8List -
Wraps raw interleaved PCM
pcmin a canonical 44-byte WAV (RIFF) header.
Exceptions / Errors
- CaptureException
- Thrown when the native capture layer reports a failure.
- MicrophoneException
-
Base class for all errors thrown by
microphone_dart. - NoBackendAvailableException
- Thrown when no registered backend can run in the current environment.
- PermissionDeniedException
- Thrown when microphone access is denied (no permission, or the user declined the OS prompt).