Prerequisites

In the beginning, we will need an audio file in our project to play. You can copy/paste any file you like, just don’t forget to add this file to your **assets** in **pubspec.yaml** file after **flutter** :

Image for post

Now, we can start adding code for our asset player code.

Installation

Our first step would be adding **audioplayers**dependency to our Flutter project:

dependencies:
  audioplayers: ^0.15.1

Next, we need to import it…

import 'package:audioplayers/audioplayers.dart';

For handling audio files that are stored locally in our App we will need to import **audio_cache.dart** from the **audioplayers** package:

import 'package:audioplayers/audio_cache.dart';

#assets #audio #players #flutter

How to Create an Asset Audio Player in Flutter
51.45 GEEK