Managing playlists in Flutter with Just Audio

Suragch
13 min readMay 2, 2021

Loading, looping, seeking, shuffling, and editing

This tutorial will teach you how to play and navigate multiple songs using the Just Audio plugin for Flutter. You’ll learn about loading audio sources, seeking to another song, repeating a song or playlist, randomizing the song order, and editing the contents of the playlist. If you’re new to Just Audio, you should go through the previous tutorials first since this one will assume you’re already familiar with the basics:

  1. Playing short audio clips in Flutter with Just Audio
  2. Streaming audio in Flutter with Just Audio

Setup

Rather than walking you through the entire UI and state management setup process again, this time I’ll provide you with a starter project. The starter project begins where the last tutorial left off, that is, with streaming a single audio file from a URL.

Getting the starter project

Download or clone the GitHub repository for the project:

git clone https://github.com/suragch/audio_playlist_flutter_demo.git

Then open the starter folder in your IDE.

Running the app

Run the app to see where the starter project begins.

Starter app

This will play a single song when you press the play button just like you did in the Just Audio steaming tutorial. None of the other buttons work yet, though. I’ve added them to the UI, but they’re missing the logic to make them do anything. That’s your job. By the end of the tutorial you’ve have them all working well.

Exploring the starter code

Go ahead and browse the UI widgets in main.dart now. You’ll see that I wrapped some widgets with a ValueListenableBuilder. These widgets will rebuild when there’s a state change. This is a simple state management…

--

--