Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mute the sound of buttons in application?

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.

like image 718
Kostya Vyrodov Avatar asked Jan 27 '26 15:01

Kostya Vyrodov


1 Answers

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.

like image 121
Kostya Vyrodov Avatar answered Jan 30 '26 04:01

Kostya Vyrodov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!