Microphone recording for Dart and Flutter across platforms. Native builds require Rust in addition to Dart or Flutter. Precompiled binaries are planned to remove that build requirement.
This is a melos monorepo:
| Package | What it is |
|---|---|
packages/microphone_dart |
Pure Dart (no Flutter); works in CLI tools. Reaches native microphone recording over dart:ffi. |
packages/microphone_flutter |
Flutter plugin. Builds the native library automatically (via cargokit) and re-exports the microphone_dart API. |
packages/microphone_flutter/rust |
The microphone Rust crate (the native capture library). It lives inside the plugin so the published package can build it. |
| Host | Status |
|---|---|
| Android | Working |
| iOS | Working |
| macOS | Working |
| Ubuntu 24.04 | Working |
| Web | Working |
| Windows 11 | Working |
Web tested on macOS in Chrome and Safari, Ubuntu 24.04 in Chrome and Firefox, and Windows 11 in Chrome and Edge.
Driven by melos (config lives in the root
pubspec.yaml). After dart pub get (or flutter pub get):
dart run melos run native:build # build the Rust shared library
dart run melos run analyze # analyze microphone_dart + microphone_flutter
dart run melos run format # check Dart formatting (format:fix to apply)
dart run melos run test # Dart + Flutter tests
dart run melos run test:web # web backend in headless Chrome
dart run melos run native:test # Rust crate testsMicrophone.record() preserves automatic session configuration by default.
Applications coordinating playback, capture, calls, or multiple audio libraries
can select audioSessionManagement: AudioSessionManagement.application. Configure
and activate a record-capable AVAudioSession in the application before starting
capture. In this mode microphone does not change category, activate, or deactivate
the shared session. The application owns route changes, interruptions, recovery,
and final deactivation after all playback and capture users have stopped.
Stopping one microphone recording never deactivates the shared session.
This opt-in requires native microphone ABI 3. An older native library or a custom
backend without AudioSessionCaptureBackend fails with UnsupportedError rather
than reverting to automatic session configuration. Other native platforms accept
the mode without changing their capture behavior. Microphone permission remains
required independently of session ownership. Applications using a web or simulated
backend should retain automatic mode unless that backend implements the capability.
Pure Dart and session-policy tests establish routing and ownership behavior;
physical iOS playback/capture, interruptions, and route changes require device tests.