A Flutter plugin that provides the Opus audio codec as a DynamicLibrary for use with opus_codec_dart on Flutter platforms.
This monorepo contains a federated Flutter plugin that loads libopus on each supported platform. The plugin follows the federated plugin architecture, splitting platform implementations into separate packages.
| Package | Directory | Version |
|---|---|---|
| opus_codec | opus_flutter | 3.0.5 |
| opus_codec_dart | opus_dart | 3.0.5 |
| opus_codec_platform_interface | opus_flutter_platform_interface | 3.0.5 |
| opus_codec_android | opus_flutter_android | 3.0.5 |
| opus_codec_ios | opus_flutter_ios | 3.0.5 |
| opus_codec_linux | opus_flutter_linux | 3.0.5 |
| opus_codec_macos | opus_flutter_macos | 3.0.5 |
| opus_codec_web | opus_flutter_web | 3.0.5 |
| opus_codec_windows | opus_flutter_windows | 3.0.5 |
| Android | iOS | Linux | macOS | Web | Windows |
|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Add opus_codec to your pubspec.yaml:
dependencies:
opus_codec: ^3.0.5
opus_codec_dart: ^3.0.5Platform packages are automatically included through the federated plugin system -- you don't need to add them individually.
import 'package:opus_codec/opus_codec.dart' as opus_codec;
import 'package:opus_codec_dart/opus_codec_dart.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
initOpus(await opus_codec.load());
// opus_codec_dart functions are now available
}The load() function returns a DynamicLibrary on native platforms (via dart:ffi) or a wasm_ffi DynamicLibrary on the web. See the example app for a complete encoding/decoding demo.
Dart is more than just Flutter. With this split, Flutter developers get a convenient way to load opus, while opus_codec_dart can still be used without Flutter (e.g. on headless servers). Developers are also free to load opus themselves without using opus_codec_dart.
Currently, opus 1.5.2 is bundled (on Linux, the system-installed version is used).
| Platform | Method |
|---|---|
| Android | Built from source via CMake (details) |
| iOS | Prebuilt XCFramework, supports CocoaPods and Swift Package Manager (details) |
| Linux | System library libopus.so.0 (details) |
| macOS | Prebuilt XCFramework, supports CocoaPods and Swift Package Manager (details) |
| Web | Compiled to WebAssembly with Emscripten (details) |
| Windows | Prebuilt DLLs for x86/x64 (details) |
The scripts/ directory contains helper scripts for local development.
| Script | Description |
|---|---|
scripts/unit_tests.sh |
Runs all unit tests across every package and collects per-package lcov coverage reports. When lcov is available, all reports are merged into a single coverage/lcov.info at the repository root and an HTML report is generated at coverage/html/index.html. |
scripts/analyze.sh |
Runs static analysis (flutter analyze / dart analyze) across every package and prints a pass/fail summary. Exits with a non-zero code if any package has analysis errors. |
scripts/format.sh |
Checks that all Dart code is formatted correctly (dart format --set-exit-if-changed). Exits with a non-zero code if any file needs formatting. |
scripts/check_dependencies.sh |
Reports outdated dependencies and checks pub.dev for discontinued or abandoned packages. Requires curl and python3 for the discontinued-package checks. |
scripts/publish.sh |
Publishes all packages to pub.dev in dependency order (three tiers). Runs in dry-run mode by default; pass --publish to push to pub.dev. |
./scripts/unit_tests.shThe script automatically runs dart run build_runner build --delete-conflicting-outputs for opus_codec_dart before executing its tests, so Mockito mock classes are always up to date.
Requirements:
flutter(stable channel) withdartbundledlcov(optional, for merged HTML coverage report) —brew install lcovdart pub global activate coverage(foropus_codec_dartpure-Dart coverage)
./scripts/analyze.shRequirements:
flutter(stable channel) withdartbundled
- Dart SDK
>=3.4.0 - Flutter
>=3.22.0
BSD-2-Clause. See LICENSE for details.