flutter-dart-stylelisted
Install: claude install-skill abugeek/flutter-skills
# Modern Dart & Flutter code style
Verified 2026-09-25: **Flutter 3.47.5 / Dart 3.13.4** (stable). Language features depend on the package's SDK constraint. Check `environment: sdk:` in `pubspec.yaml` before using a feature. The minimum language version is noted on each item below.
Goal: **less code, same behavior, and mistakes caught by the compiler instead of at runtime.** Don't write code the SDK, the language, or an existing dependency already provides.
## 1. Classes & models
- **Primary constructors (3.13)** declare fields and constructor in the header:
```dart
class Point(final int x, final int y); // immutable fields x, y
class const Money(final int cents, final String currency); // const primary constructor
class User({required final String _id, final String? nickname}); // 3.12 private named param: caller passes `id:`
class Admin(super.name, final Set<String> roles) extends User; // super parameters
class Temp(final double celsius) { this : assert(celsius > -273.15); } // validation
```
Widgets too (compile-checked):
```dart
class const Greeting({super.key, required final String name}) extends StatelessWidget {
@override
Widget build(BuildContext context) => Padding(padding: const .all(16), child: Text('Hi $name'));
}
```
`var`/`final` in the header creates a field. Without it, the parameter is just a parameter. Since 3.13, `final`/`var` on ordinary function parameters is a compile error.
- **Concise constructors