dartlisted
Install: claude install-skill ndisisnd/cook
# Dart Standards
## Priority: P0 — Language Correctness
### Null Safety
- Avoid `!`. Prefer local promotion, null-check patterns, and private `final` fields.
- Use `!` only for documented invariants or framework/external boundaries where non-null is guaranteed but not expressible to the analyzer.
- Prefer `?.`, `??`, and null-aware patterns over forced unwrapping.
- `AVOID late` if you need to check whether the variable was initialised — use nullable + null-check instead.
- `DON'T` explicitly initialise variables to `null`; let the type system express optionality.
### Immutability
- Use `const` > `final` > `var`. Use `@freezed` for data classes.
- Prefer `final` for all class members. Use `var` only for locally-obvious short-lived locals.
- `AVOID` public `late final` fields without initializers.
### Pattern Matching (Dart 3.x)
Use `switch` expressions with exhaustive patterns and destructuring. Supported pattern types:
| Pattern | Example |
|---|---|
| Constant | `case 42:` |
| Variable | `case var x:` |
| Wildcard | `case _:` |
| Object | `case Circle(radius: var r):` |
| Record | `case (String name, int age):` |
| List | `case [first, ...rest]:` |
| Map | `case {'key': var v}:` |
| Logical-or | `case 1 || 2:` |
| Guard | `case var x when x > 0:` |
```dart
String describe(Shape s) => switch (s) {
Circle(radius: var r) when r > 10 => 'large circle',
Circle(radius: var r) => 'circle r=$r',
Rectangle(width: var w, height: var h) => '${w}x$h rect',
};
```
### Recor