DEV Community

kanta13jp1
kanta13jp1

Posted on

Claude Schedule Auto-Generated Flutter Pages That Failed CI — Quality Gates for AI-Generated Code

Claude Schedule Auto-Generated Flutter Pages That Failed CI

Setup: Claude Schedule Handles Customer Support

Every hour, a Claude Code Schedule job reads support tickets and generates Flutter pages as needed:

# cs-check.yml
on:
  schedule:
    - cron: '0 * * * *'
Enter fullscreen mode Exit fullscreen mode

The problem: AI-generated Dart code has quality variance. Over several sessions of hourly generation, lint errors accumulated.

The Errors

error - Missing a required trailing comma - leave_management_page.dart:76:8
error - 'value' is deprecated. Use initialValue instead - leave_management_page.dart:154:21
error - Missing a required trailing comma - performance_review_page.dart:82:8
error - Missing a required trailing comma - pomodoro_timer_page.dart:129:8
(22 total across 3 files)
Enter fullscreen mode Exit fullscreen mode

All from pages auto-generated by the CS-check schedule. No human reviewed them between generation and push.

The Fix

dart fix --apply lib/
dart format lib/pages/leave_management_page.dart \
            lib/pages/performance_review_page.dart \
            lib/pages/pomodoro_timer_page.dart
flutter analyze lib/
# → No issues found!
Enter fullscreen mode Exit fullscreen mode

dart fix --apply handles require_trailing_commas automatically. The deprecated valueinitialValue fix came along with it.

Prevention: Add Lint Step to CS-Check Workflow

# cs-check.yml — add after any Dart file generation
- name: Lint generated Dart files
  if: steps.generate_page.outputs.dart_files != ''
  run: |
    dart fix --apply lib/
    dart format lib/ --set-exit-if-changed
    flutter analyze lib/
  continue-on-error: false  # skip commit if lint fails
Enter fullscreen mode Exit fullscreen mode

With continue-on-error: false, a lint failure aborts the commit. CI stays green.

The DropdownButtonFormField Deprecation

Flutter 3.33+ deprecated the value: parameter on DropdownButtonFormField:

// ❌ Deprecated (Flutter 3.33+)
DropdownButtonFormField<String>(value: _selected, ...)

// ✅ Current
DropdownButtonFormField<String>(initialValue: _selected, ...)
Enter fullscreen mode Exit fullscreen mode

AI models trained before Flutter 3.33 generate the old form. The fix: add version constraints to Claude's system prompt:

Flutter version: 3.38
- DropdownButtonFormField: use initialValue, not value
- All trailing arguments must have trailing commas (require_trailing_commas is enabled)
Enter fullscreen mode Exit fullscreen mode

Explicit version context reduces the frequency of deprecated API usage in generated code.

Takeaways

Problem Fix
Trailing commas missing dart fix --apply in CI step
Deprecated API usage Version constraints in system prompt
Error accumulation Lint step in generation workflow

The core principle: lint AI-generated code at generation time, not code-review time. CI catches 100% of these issues; human review of auto-generated code is unreliable.


Building in public: https://my-web-app-b67f4.web.app/

ClaudeCode #Flutter #CI/CD #buildinpublic

Top comments (0)