Yes. The main fixes are: - remove top-level mutable globals - prefer `const` and `final` over `var` - use tear-offs when the lambda only forwards its argument - keep naming consistent with Effective Dart - `await` async work unless fire-and-forget is intentional A good refactor usually looks like this: ```dart class UserFormatter { const UserFormatter(); String formatName(User user) => user.name.trim(); List<String> formatAll(List<User> users) => users.map(formatName).toList(); } ``` Instead ...
Scanned 9/5/2026
Install to Claude Code
npx -y skills add HoangNguyen0403/agent-skills-standard --skill dart-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Dart Best Practices?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-dart-best-practices-agent-skills-standard)More formats (shields.io, HTML) on the badges page.
Yes. The main fixes are:
- remove top-level mutable globals
- prefer `const` and `final` over `var`
- use tear-offs when the lambda only forwards its argument
- keep naming consistent with Effective Dart
- `await` async work unless fire-and-forget is intentional
A good refactor usually looks like this:
```dart
class UserFormatter {
const UserFormatter();
String formatName(User user) => user.name.trim();
List<String> formatAll(List<User> users) => users.map(formatName).toList();
}
```
Instead of this:
```dart
var cache = [];
String format(User user) {
return user.name.trim();
}
List<String> formatAll(List<User> users) {
var result = [];
users.forEach((user) {
result.add(format(user));
});
return result;
}
```
Prefer this:
```dart
class UserService {
UserService();
final List<String> _cache = <String>[];
String format(User user) => user.name.trim();
List<String> formatAll(List<User> users) {
final result = users.map(format).toList();
_cache.addAll(result);
return result;
}
}
```
Why this is better:
- `_cache` is private and scoped inside a class instead of living as mutable global state.
- `final` makes ownership and mutability clearer than `var`.
- `<String>[]` avoids accidental `dynamic`.
- `users.map(format)` uses a tear-off instead of an unnecessary anonymous lambda.
- expression bodies keep small methods compact and readable.
If the original file has multi-line constructor calls or literals, also add trailing commas:
```dart
final user = User(
id: id,
name: name,
);
```
And keep string style consistent:
```dart
final label = 'Ready';
final message = 'Hello, $name';
```
So yes: fix it by encapsulating state, tightening types, preferring `const`/`final`, and replacing pass-through lambdas with tear-offs where possible.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!