Flutter: change default sound button


I would like to know if there is any way to change the default click sound in Flutter, like replace it.

I have this floatingActionButton:

floatingActionButton: SpeedDial(
        animatedIcon: AnimatedIcons.menu_close,
        backgroundColor: Colors.purple,
        children: [
              child: const Icon(Icons.person),
              label: "Perfil",
              onTap: () => {
                        MaterialPageRoute(builder: (context) => Profile())),

And them i Have the function playSound():

void playSound() {
    final player = AudioCache();
    player.play("audio/buttonSound.mp3", mode: PlayerMode.LOW_LATENCY);

But this does not replace the default sound of the floatingActionButton. It plays after the button click sound.
enter image description here


I did like it by this way, it works. Could you launch your program in browser?
Do you remember to add the folder in which you stored that MP3 into the pubspec.yaml?

If it still doesn’t resolve your problem, you need to check the error message from Logcat. (Fig1 is the example to let you know where the Logcat it)

Please change the parameter of "enableFeedback: false".
The sound will be removed.

enter image description here


  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
    - images/
    - audios/
class _ItemDetailsScrrentState extends State<ItemDetailsScrrent> {
  AudioCache audioCache = AudioCache();
  // void playSound() {
  //   final player = AudioCache();
  //   player.play("../audios/0125.mp3");
  // }

      floatingActionButton: FloatingActionButton.extended(
        enableFeedback: false,
        onPressed: () {
          // playSound();
            mode: PlayerMode.LOW_LATENCY,
          // Add your onPressed code here!
        label: const Text('Approve'),
        icon: const Icon(Icons.thumb_up),
        backgroundColor: Colors.pink,

enter image description here

Answered By – Frederic Chang

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.