我正在使用 hardware_buttons: ^1.0.0. 但它只检测到您按下按钮时,而不是当您释放它时。
StreamSubscription _volumeButtonSubscription;
init{
...
_volumeButtonSubscription = volumeButtonEvents.listen((VolumeButtonEvent event) {
if(event.toString().contains("VolumeButtonEvent.VOLUME_UP")){
//this part is when the user press volume up
}
});
}