Skip to content
Back to skills

Dart Language

ASecurity

The safer approach is to stop force-unwrapping and make the null case explicit in your control flow. In modern Dart, `!` should be the exception, not the default. Prefer one of these patterns instead: 1. Guard early with an `if` ```dart void greet(String? name) { if (name == null) { print('Missing name'); return; } print('Hello, $name'); } ``` 2. Use `??` for a fallback value ```dart String displayName(String? name) => name ?? 'Guest'; ``` 3. Use `?.` when accessing members on a nullable valu...

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
development

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill dart-language --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dart Language?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dart Language
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-dart-language-41cdbec4/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-dart-language-41cdbec4)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
The safer approach is to stop force-unwrapping and make the null case explicit in your control flow.

In modern Dart, `!` should be the exception, not the default. Prefer one of these patterns instead:

1. Guard early with an `if`

```dart
void greet(String? name) {
  if (name == null) {
    print('Missing name');
    return;
  }

  print('Hello, $name');
}
```

2. Use `??` for a fallback value

```dart
String displayName(String? name) => name ?? 'Guest';
```

3. Use `?.` when accessing members on a nullable value

```dart
int nameLength(String? name) => name?.length ?? 0;
```

4. Narrow once, then use the non-null local value

```dart
void sendEmail(String? email) {
  if (email case final value?) {
    print('Sending to $value');
    return;
  }

  print('No email provided');
}
```

Why this is better than repeated `!`:

- It prevents runtime null-assertion crashes.
- It documents what should happen when the value is absent.
- It keeps the code aligned with Dart’s null-safety model instead of bypassing it.

If you find yourself writing `value!` everywhere, that usually means one of two things:

- the variable should not be nullable in the first place, so tighten the type to `String`
- the null case is real, so handle it once near the boundary and pass a non-null value deeper into the code

In short: prefer `if`, `?.`, `??`, and pattern-based null checks; only use `!` when you can prove non-nullness at that exact point.

Files in this skill

  • eval-1.baseline.md1.8 KB
  • eval-1.with-skill.md1.5 KB
  • eval-2.baseline.md2 KB
  • eval-2.with-skill.md1.4 KB
  • eval-3.baseline.md2.3 KB
  • eval-3.with-skill.md1.4 KB
  • trigger-1.md183 B
  • trigger-2.md209 B
  • trigger-3.md196 B
  • trigger-4.md216 B
  • trigger-5.md176 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.