flutter-build
Fix Dart analyzer errors and Flutter build failures incrementally. Invokes the dart-build-resolver agent for minimal, surgical fixes.
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
# Analysisflutter analyze 2>&1
# Dependenciesflutter pub get 2>&1
# Code generation (if project uses build_runner)dart run build_runner build --delete-conflicting-outputs 2>&1
# Platform buildsflutter build apk 2>&1flutter build web 2>&1Example Session
User: /flutter-build
Agent:# Flutter Build Resolution
## Initial Diagnostics
```$ flutter analyzeAnalyzing 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<Item>'. Try correcting the name to the name of an existing method, or defining a method named 'add'. • undefined_method
2 errors found.```
## Fix 1: Null Safety
File: lib/features/user/data/user_repository_impl.dart:34Error: A value of type 'String?' can't be assigned to type 'String'
Changed:```dartfinal id = response.id;```To:```dartfinal id = response.id ?? '';```
```$ flutter analyze1 error found.```
## Fix 2: Immutable List
File: lib/features/cart/presentation/cart_page.dart:58Error: The method 'add' isn't defined for the type 'List<Item>'Cause: State holds an unmodifiable list; mutation goes through Cubit
Changed:```dartstate.items.add(item);```To:```dartcontext.read<CartCubit>().addItem(item);// Note: Cubit exposes named methods (addItem, removeItem);// .add(event) is the BLoC event API — don't mix them.```
```$ flutter analyzeNo issues found!```
## Final Verification
```$ flutter testAll 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 qualityverification-loopskill — Full verification loop
Related
- Agent:
agents/dart-build-resolver.md - Skill:
skills/flutter-dart-code-review/