Skip to content

Instantly share code, notes, and snippets.

@yjbanov
Created May 26, 2024 04:57
Show Gist options
  • Save yjbanov/22e076c2db55cf2d8d773e922472d5d6 to your computer and use it in GitHub Desktop.
Save yjbanov/22e076c2db55cf2d8d773e922472d5d6 to your computer and use it in GitHub Desktop.
@pragma('dart2js:tryInline')
bool get assertionsEnabled {
var enabled = false;
assert(enabled = true);
return enabled;
}
// Elsewhere
void main() {
if (assertionsEnabled) {
// assert here; this code will be tree shaken off
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment