Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Last active October 16, 2024 14:23
Show Gist options
  • Save gyugyu90/acc3db49f2decd07bdb18a899f1ebe4c to your computer and use it in GitHub Desktop.
Save gyugyu90/acc3db49f2decd07bdb18a899f1ebe4c to your computer and use it in GitHub Desktop.
class NoiseCancellingHeadphone extends BluetoothHeadphone {
bool noiseCancellingEnabled = false;
@override
double get volumeUnit => 0.2;
void toggleNoiseCancelling() {
noiseCancellingEnabled = !noiseCancellingEnabled;
}
@override
void increaseVolume() {
super.increaseVolume();
_playVolumeSoundEffect();
}
@override
void decreaseVolume() {
super.decreaseVolume();
_playVolumeSoundEffect();
}
_playVolumeSoundEffect() {
print('🎵');
}
}
void main() {
NoiseCancellingHeadphone noiseCancellingHeadphone =
NoiseCancellingHeadphone();
noiseCancellingHeadphone.decreaseVolume(); // 🎵
print(noiseCancellingHeadphone.volume); // 4.8
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment