Audio playback 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/sound_dart |
Pure Dart (no Flutter); works in CLI tools. Reaches native audio over dart:ffi, with a pluggable backend registry. |
packages/sound_flutter |
Flutter plugin. Builds the native library automatically (via cargokit) and re-exports the sound_dart API. |
packages/sound_flutter/rust |
The sound_cli Rust crate (the C ABI behind the FFI backend), kept inside sound_flutter so it ships with that package. Decodes WAV/MP3/OGG/FLAC and plays with no system deps - loads the OS audio library at runtime: libasound.so.2 on Linux, libaaudio.so on Android, AudioToolbox on macOS/iOS, winmm.dll on Windows. |
import 'package:sound_dart/sound_dart.dart';
final playback = await Sound.playFile('chime.wav', volume: 0.8);
await playback.onComplete;Build the native library first: cargo build --manifest-path packages/sound_flutter/rust/Cargo.toml.
| Host | Status |
|---|---|
| Android | Working |
| Android Emulator | Working |
| iOS | Working |
| iOS Simulator | Working |
| macOS | Working |
| Ubuntu 24.04 | Working |
| Web | Working |
| Windows 11 | Working |
Android Emulator tested on macOS, Ubuntu 24.04, and Windows 11. 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 sound_dart + sound_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 native:test # Rust crate teststool/consumer_build.sh linux apk builds a fresh flutter create app
against the two packages exported the way pub.dev ships them, and
flutter test integration_test -d <device> (from
packages/sound_flutter/example) runs the on-device playback tests.
- Run the example and the integration tests on each platform's real hardware, Windows and Apple devices included.
- Push a
v*tag to GitHub so.github/workflows/precompile.ymlpublishes the signed prebuilt libraries for the crate's current hash. - Publish
sound_dartfirst, thensound_flutter, which depends on the hostedsound_dart.