The OGG, Opus, Vorbis, and FLAC libraries are enabled by default in flutter_soloud (built from source via native hooks). However, if you don't need streaming capabilities, you can exclude these libraries to reduce your app's binary size by 600~3000 KB (depending on platform).
For a complete guide on building from source, using system packages, or downloading prebuilt binaries, see the Xiph Libraries & Codecs Guide.
Native code for mobile and desktop (Android, iOS, macOS, Windows, Linux) is compiled using Dart build hooks.
To build your application without the bundled Opus, Ogg, Vorbis, and FLAC libraries, add the hooks.user_defines block to your root app's pubspec.yaml:
hooks:
user_defines:
flutter_soloud:
no_xiph_libs: trueThat's it! Dart's build hook will automatically:
- Define
NO_XIPH_LIBSduring C/C++ native compilation. - Skip linking and bundling the prebuilt Xiph libraries.
- Track this configuration in
.dart_tool/hooks_runner/so rebuilding and switching configurations invalidates and recompiles automatically across all native platforms.
Environment Variables Notice: In previous versions of flutter_soloud, NO_XIPH_LIBS was configured via shell environment variables, Podfile, or Gradle properties. Under the Dart Native Assets Hooks build system, Dart/Flutter runs hooks in a hermetic build environment and manages configuration deterministically via user_defines in pubspec.yaml. Shell environment variables (e.g. export NO_XIPH_LIBS=1) or .vscode/launch.json env are no longer used for build-time configuration.
For the Web platform (which uses Emscripten / WebAssembly rather than Dart native build hooks):
- Open
web/compile_wasm.shin theflutter_soloudpackage. - Change
NO_XIPH_LIBS="0"toNO_XIPH_LIBS="1". - Rebuild the WASM binaries by executing
web/compile_wasm.sh.
Requirements:
- Emscripten installed
- Linux or macOS for compilation (Windows users can use WSL)
When built without Opus/Vorbis/FLAC:
setBufferStream()andreadSamplesFrom*()using Opus/Vorbis/FLAC formats will throw exceptions- Other audio formats (MP3, WAV) and synthesis features remain fully functional
- Binary size is reduced by 600~3000 KB depending on target architecture
- All other features work normally