stereo 1.0.0

  • Example
  • Installing
  • Versions
  • 70

Stereo plugin for Flutter

A Flutter plugin for playing music on iOS and Android.


  • Play/pause
  • Stop
  • Duration / seek to position
  • Load track from path
  • Load track from library


First, add stereo as a dependency in your pubspec.yaml file.


Add the following permission to your AndroidManifest.xml file:

  • <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>


Add the following key to your Info.plist file:

  • NSAppleMusicUsageDescription




Feel free to contribute by opening issues and/or pull requests. Your feedback is very welcome!


This project is licensed under the MIT License. See LICENSE file for more information.


  • Initial release


import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;

import 'package:path_provider/path_provider.dart';
import 'package:stereo/stereo.dart';
import 'package:stereo_example/media_info_widget.dart';

import 'package:stereo_example/media_player_widget.dart';

void main() {
  runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: 'Stereo Plugin Example', home: new HomeScreen());

class HomeScreen extends StatefulWidget {
  _HomeScreenState createState() => new _HomeScreenState();

class _HomeScreenState extends State<HomeScreen> {
  Stereo _stereo = new Stereo();

  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(title: new Text('Stereo Plugin Example')),
        body: new Column(children: <Widget>[
          new Center(
              heightFactor: 1.5,
              child: new Text('Choose an action:',
                  style: new TextStyle(
                      fontWeight: FontWeight.bold, fontSize: 20.0))),
          new Wrap(
              alignment: WrapAlignment.spaceAround,
              spacing: 12.0,
              runSpacing: 8.0,
              children: <Widget>[
                new RaisedButton(
                    child: new Text('Play dubstep.mp3'),
                    onPressed: () => _playFile('dubstep.mp3')),
                new RaisedButton(
                    child: new Text('Play pi.mp3'),
                    onPressed: () => _playFile('pi.mp3')),
                new RaisedButton(
                    child: new Text('Invalid URL'),
                    onPressed: () => _playFile("invalid_file.mp3")),
                new RaisedButton(
                    child: new Text('Pick file'), onPressed: () => _pickFile())
          new Container(height: 5.0),
          new MediaInfoWidget(),
          new Padding(
                  new EdgeInsets.symmetric(vertical: 5.0, horizontal: 10.0),
              child: new MediaPlayerWidget())

  Future _pickFile() async {
    try {
      AudioTrack track = await _stereo.picker();

      _playFile(track.path, false);
    } on StereoPermissionsDeniedException catch (_) {
      print('ERROR: Permissions denied');
    } on StereoNoTrackSelectedException {
      print('ERROR: No track selected');

  Future _playFile(String file, [bool fromAppDir = true]) async {
    String dir = '';

    if (fromAppDir) {
      await _copyFiles();

      await getApplicationDocumentsDirectory().then(
          (Directory directory) => dir = 'file://' + directory.path + '/');

    try {
      await _stereo.load('$dir$file');
    } on StereoFileNotPlayableException {
      var alert = new AlertDialog(
          title: new Text('File not playable'),
          content: new Text('The file you specified is not playable.'));

      showDialog(context: context, child: alert);

  // Don't judge the code for this method, it's for the example...
  Future _copyFiles() async {
    final Directory dir = await getApplicationDocumentsDirectory();

    final File dubstepSong = new File('${dir.path}/dubstep.mp3');
    final File piSong = new File('${dir.path}/pi.mp3');

    if (!(await dubstepSong.exists())) {
      final data = await rootBundle.load('assets/songs/dubstep.mp3');
      final bytes = data.buffer.asUint8List();
      await dubstepSong.writeAsBytes(bytes, flush: true);
    if (!(await piSong.exists())) {
      final data = await rootBundle.load('assets/songs/pi.mp3');
      final bytes = data.buffer.asUint8List();
      await piSong.writeAsBytes(bytes, flush: true);

1. Depend on it

Add this to your package's pubspec.yaml file:

  stereo: "^1.0.0"

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:stereo/stereo.dart';
Version Uploaded Documentation Archive
1.0.0 Mar 20, 2018 Go to the documentation of stereo 1.0.0 Download stereo 1.0.0 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6
  • Flutter: 0.3.2


Describes how popular the package is relative to other packages. [more]
40 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 hints.

    Run flutter format to format lib/src/audio_track.dart.

    Run flutter format to format lib/stereo.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.9
meta 1.1.2
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6
Dev dependencies