Installation

Learn how to set up flutter_soloud in your project

Platform Setup

Web Platform

To use this plugin on the web platform, add the following scripts to your index.html:

<script src="assets/packages/flutter_soloud/web/libflutter_soloud_plugin.js" defer></script>
<script src="assets/packages/flutter_soloud/web/init_module.dart.js" defer></script>

See the Web Platform Guide for more details.

Linux Setup

Linux distributions require the ALSA library for audio support. If missing, install it using your package manager:

# Debian/Ubuntu
sudo apt-get install libasound2-dev

# Arch Linux
sudo pacman -S alsa-lib

# OpenSUSE
sudo zypper install alsa-devel

iOS Configuration

When creating a release archive (IPA), you may need to modify symbol stripping to prevent errors:

  1. Open your project in Xcode
  2. Navigate to Target Runner > Build Settings > Strip Style
  3. Change from "All Symbols" to "Non-Global Symbols"

Basic Usage

Initialize SoLoud in your app:

void main() async {
  await SoLoud.instance.init(
    sampleRate: 44100,      // Audio quality
    bufferSize: 2048,       // Buffer size affects latency
    channels: Channels.stereo,
  );
  
  runApp(const MyApp());
}
The bufferSize parameter affects audio latency, which generally means the time it takes from triggering a sound to the sound actually coming out of the speakers. The smaller the latency, the better, but could lead to choppy audio depending on the complexity of the audio processing. The default is 2048, but it can be adjusted to 1024 or 512.

Best Practices

  • Initialize SoLoud early in your app lifecycle
  • Handle initialization errors appropriately
  • Configure buffer size based on your latency and app needs
  • Clean up resources when your app closes