dart
Language-specific super-code guidelines for dart.
Dart: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for dart.
Table of Contents
- [Null Safety](#nulls)
- [Collections & Iteration](#collections)
- [Classes & Records](#classes)
- [Async/Await & Streams](#async)
- [Error Handling](#errors)
- [Flutter-Specific Patterns](#flutter)
- [Anti-patterns specific to Dart](#antipatterns)
1. Null Safety {#nulls}
// ❌ Manual null check
String display;
if (user.name != null) {
display = user.name!;
} else {
display = 'Unknown';
}
// ✅
final display = user.name ?? 'Unknown';
// ❌ Nested null checks
if (user != null && user.address != null && user.address!.city != null) {
print(user.address!.city!);
}
// ✅
final city = user?.address?.city;
if (city != null) print(city);
// ❌ Late field when nullable is correct
late String name; // crashes if accessed before assignment
// ✅ — use late only when you guarantee initialization before access
String? name; // honestly nullable
// late is fine for: late final _controller = TextEditingController();
// ❌ Bang operator (!) everywhere
final name = user.name!;
final city = user.address!.city!;
// ✅ — promote through null checks
final name = user.name;
if (name == null) return;
// name is now non-null (promoted)
2. Col
Subscribers only
The full skill, its 1 bundled files and every download is included with every paid Complete AI plan.
Details
| Source | community |
|---|---|
| License | — |
| Risk label | safe ("critical" means the skill may run commands or touch files — read before use) |
| Files | SKILL.md |
| Added | 2026-06-16 |
