Files
everything-claude-code/rules/dart/hooks.md
2026-04-02 17:48:43 -07:00

1.3 KiB

paths
paths
**/*.dart
**/pubspec.yaml
**/analysis_options.yaml

Dart/Flutter Hooks

This file extends common/hooks.md with Dart and Flutter-specific content.

PostToolUse Hooks

Configure in ~/.claude/settings.json:

  • dart format: Auto-format .dart files after edit
  • dart analyze: Run static analysis after editing Dart files and surface warnings
  • flutter test: Optionally run affected tests after significant changes
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": { "tool_name": "Edit", "file_paths": ["**/*.dart"] },
        "hooks": [
          { "type": "command", "command": "dart format $CLAUDE_FILE_PATHS" }
        ]
      }
    ]
  }
}

Pre-commit Checks

Run before committing Dart/Flutter changes:

dart format --set-exit-if-changed .
dart analyze --fatal-infos
flutter test

Useful One-liners

# Format all Dart files
dart format .

# Analyze and report issues
dart analyze

# Run all tests with coverage
flutter test --coverage

# Regenerate code-gen files
dart run build_runner build --delete-conflicting-outputs

# Check for outdated packages
flutter pub outdated

# Upgrade packages within constraints
flutter pub upgrade