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.
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.
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.
To mute the sound of the button
ElevatedButton
(
style: ElevatedButton.styleFrom(
//this enable feedback helps to turn off the sound on click
enableFeedback: false,
),
I wanted to do this for a TextButton widget.
To disable the sound I added the following property:
style: ButtonStyle(
enableFeedback: false,
),