Skip to content

Instantly share code, notes, and snippets.

@timsneath
Created October 22, 2020 17:22
Show Gist options
  • Save timsneath/6f1e43d6cefe99b4d52913086dc32379 to your computer and use it in GitHub Desktop.
Save timsneath/6f1e43d6cefe99b4d52913086dc32379 to your computer and use it in GitHub Desktop.
void honk(int? loudness) {
if (loudness == null) {
// No loudness specified, notify the developer
// with maximum loudness.
_playSound('error.wav', volume: 11);
return;
}
// Loudness is non-null, let's just clamp it to acceptable levels.
_playSound('honk.wav', volume: loudness.clamp(0, 11));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment