Skip to content

Instantly share code, notes, and snippets.

@mono0926
Created March 17, 2022 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0926/8d29b35ca9bc0ec984ee6fb9a22baa37 to your computer and use it in GitHub Desktop.
Save mono0926/8d29b35ca9bc0ec984ee6fb9a22baa37 to your computer and use it in GitHub Desktop.
const condition = false;
void main() {
// {} 省略はミスの元なので一般的に良くないと言われているけどdart format前提ならミスしなさそうで、ありな気もする🤔
// https://dart-lang.github.io/linter/lints/always_put_control_body_on_new_line.html
if (condition) throw Exception('hello');
// `throw`の前で改行してFix Allすると自動的に {} 付けてくれて便利
if (condition) {
throw Exception('hello');
}
final list = [
1,
2,
// ちょっと違うけど、Dart 2.3 での collection if も似てる
// https://dart.dev/guides/language/language-tour#collection-operators
// https://medium.com/dartlang/announcing-dart-2-3-optimized-for-building-user-interfaces-e84919ca1dff
if (condition) 3,
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment