Last active
October 16, 2024 14:23
-
-
Save gyugyu90/acc3db49f2decd07bdb18a899f1ebe4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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