Flutter Build and Fix
This command invokes the dart-build-resolver agent to incrementally fix Dart/Flutter build errors with minimal changes.
What This Command Does
- Run Diagnostics: Execute
flutter analyze,flutter pub get - Parse Errors: Group by file and sort by severity
- Fix Incrementally: One error at a time
- Verify Each Fix: Re-run analysis after each change
- Report Summary: Show what was fixed and what remains
When to Use
Use /flutter-build when:
flutter analyzereports errorsflutter buildfails for any platformdart pub get/flutter pub getfails with version conflictsbuild_runnerfails to generate code- After pulling changes that break the build
Diagnostic Commands Run
# Analysis
flutter analyze 2>&1Dependencies
flutter pub get 2>&1Code generation (if project uses build_runner)
dart run build_runner build --delete-conflicting-outputs 2>&1Platform builds
flutter build apk 2>&1
flutter build web 2>&1
Example Session
User: /flutter-build
Agent:
Flutter Build Resolution
Initial Diagnostics
$ flutter analyze Analyzing project...
error • lib/features/user/data/user_repository_impl.dart:34:16 • A value of type 'String?' can't be assigned to a variable of type 'String'. • invalid_assignment
error • lib/features/cart/presentation/cart_page.dart:58:5 •
The method 'add' isn't defined for the type 'List
2 errors found.
Fix 1: Null Safety
File: lib/features/user/data/user_repository_impl.dart:34
Error: A value of type 'String?' can't be assigned to type 'String'
Changed:
dart
final id = response.id;
To:
dart
final id = response.id ?? '';
$ flutter analyze
1 error found.
Fix 2: Immutable List
File: lib/features/cart/presentation/cart_page.dart:58
Error: The method 'add' isn't defined for the type 'List<Item>'
Cause: State holds an unmodifiable list; mutation goes through Cubit
Changed:
dart
state.items.add(item);
To:
dart
context.read
$ flutter analyze
No issues found!
Final Verification
$ flutter test
All tests passed.
Summary
| Metric | Count |
|--------|-------|
| Analysis errors fixed | 2 |
| Files modified | 2 |
| Remaining issues | 0 |
Build Status: PASS ✓
Common Errors Fixed
| Error | Typical Fix |
|-------|-------------|
| A value of type 'X?' can't be assigned to 'X' | Add ?? default or null guard |
| The name 'X' isn't defined | Add import or fix typo |
| Non-nullable instance field must be initialized | Add initializer or late |
| Version solving failed | Adjust version constraints in pubspec.yaml |
| Missing concrete implementation of 'X' | Implement missing interface method |
| build_runner: Part of X expected | Delete stale .g.dart and rebuild |
Fix Strategy
- Analysis errors first — code must be error-free
- Warning triage second — fix warnings that could cause runtime bugs
- pub conflicts third — fix dependency resolution
- One fix at a time — verify each change
- Minimal changes — don't refactor, just fix
Stop Conditions
The agent will stop and report if:
- Same error persists after 3 attempts
- Fix introduces more errors
- Requires architectural changes
- Package upgrade conflicts need user decision
Related Commands
/flutter-test— Run tests after build succeeds/flutter-review— Review code quality/verify— Full verification loop
Related
- Agent:
agents/dart-build-resolver.md - Skill:
skills/flutter-dart-code-review/