Playing short audio clips in Flutter with Just Audio

Suragch
5 min readApr 23, 2021

This article was updated on March 4, 2024 for Flutter 3.19.

There are a million variables when talking about playing audio in a Flutter app, so this tutorial will seek to limit the scope to one basic task: playing short audio clips. Short audio clips don’t require a background service, setting a playlist, seeking to some position, buffering, or adjusting playback speed. That makes this an ideal topic for your first audio tutorial in Flutter.

There are a number of audio packages on Pub, but this tutorial will be using Just Audio. It supports Android, iOS, web, macOS, Windows, and Linux.

Short audio clips are used in many types of apps. Here are a few examples:

  • Game sounds
  • Button click sounds
  • Language learning app
  • Dictionary with recorded audio

These sounds are all likely to be just a few seconds long at the most. You can also use Just Audio to play longer media items like songs and podcasts, but this tutorial won’t cover that today.

Follow along step by step to get the most out of this lesson.

Setup

Creating the UI layout

--

--