class SliderMune { ... }
typedef Predicate<T> = bool Function(T value);
class Foo {
const Foo([Object? arg]);
}
@Foo(anArg)
calss A { ... }
const foo = Foo();
@foo
class C { ... }
extension MyNameList<T> on List<T> { ... }
var nameModel = "Manjee.official"
// Good case
my_pakage
-> lib
-> file_system.dart
-> bottom_menu.dart
// Bad case
mypakage
-> lib
-> file-system.dart
-> bottomMenu.dart
// Good case
import 'dart:math' as math;
import 'package:angular_components/angular_components.dart' as angular_components;
import 'package:js/js.dart' as js;
// Bad case
import 'dart:math' as Math;
import 'package:angular_components/angular_components.dart' as angularComponents;
import 'package:js/js.dart' as JS;
var githubId = "manjee";
HttpRequest httpRequest;
void align(bool clearItems) { ... }
// Good case
const pi = 3.14l
const defaultTimeout = 1000;
final urlScheme = RegExp('^([a-z]+):');
class Dice {
static final numberGenerator = Random();
}
SCREAMING_CAPS
- SCREAMING_CAPS 형태 네이밍의 변수를 사용하고 있는 기존 코드나 라이브러리를 사용할 경우
- Dart 코드를 Java 코드와 병행해서 개발할 경우
class HttpConnection {}
class DBIOPort {}
class MrRogers {}
var uiHandler = ...
futureOfVoid.then((_) {
print('Operation complete.');
});
// Bad case
library my_library
// Good case
@TestOn('browser')
library;
import 'dart:async';
import 'dart:html';
import 'package:bar/bar.dart';
import 'package:foo/foo.dart';
import 'foo.dart';
import 'foo/foo.dart';
export 'src/error.dart';
출처 - https://dart-ko.dev/guides/language/effective-dart/style