3

Is there any way to mute click sound in android? I need to use my own sound effects.

Note: I don't want to use gesture detector instead of default button widgets, because it affects plenty of my screens.

Kostya Vyrodov
  • 6,257
  • 5
  • 23
  • 34

3 Answers3

7

I didn't find any property in default Flutter buttons.

But I think, I found the source of sound. This's InkWell widget. I did the trick below and it helped me:

class SilentBtn extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.red,
      child: Material(
        child: InkWell(
          onTap: () => print('OnTap'),
          enableFeedback: false,
          child: Container(
            width: 50,
            height: 50,
            child: Center(
              child: Text(
                ':)',
                style: TextStyle(color: Colors.white, fontSize: 16),
              ),
            ),
          ),
        ),
        color: Colors.transparent,
      ),
    );
  }
}

If you set the 'enableFeedback: false' you won't here click sound. If it's true then the sound is hearable.

Kostya Vyrodov
  • 6,257
  • 5
  • 23
  • 34
4

To mute the sound of the button

ElevatedButton
(
              style: ElevatedButton.styleFrom(
                //this enable feedback helps to turn off the sound on click
                enableFeedback: false,
              ),
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Prakash Basnet
  • 121
  • 2
  • 2
0

I wanted to do this for a TextButton widget.

To disable the sound I added the following property:

style: ButtonStyle(
            enableFeedback: false,
          ),
Sleewok
  • 153
  • 8