Claude Code Flutter LSP Setup Guide

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

Connecting Claude Code to Flutter’s Language Server Protocol gives Claude real-time access to Dart type information, widget trees, and compilation errors. This means Claude can suggest widget refactors, fix type mismatches, and generate platform-specific code with full awareness of your project’s type system.

The Problem

Flutter projects have deep widget hierarchies, complex state management patterns, and platform-specific APIs. When Claude Code works on a Flutter project without LSP integration, it lacks type context. It cannot see that a Widget is actually a StatefulWidget with specific state fields, or that a method call has a type error. This leads to suggestions that look correct but fail at compile time.

Quick Solution

  1. Ensure Flutter SDK is on your PATH:
flutter --version
dart --version
  1. Verify the Dart analysis server works:
dart language-server --protocol=lsp
  1. Configure Claude Code to use the Dart LSP in your project’s CLAUDE.md:
# Flutter LSP Integration
- Dart analysis server provides type checking
- Run `dart analyze` before accepting any code changes
- Run `flutter test` after modifying widget code
  1. Create a hook to validate changes automatically. Add to .claude/hooks/post-edit.sh:
#!/bin/bash
dart analyze --fatal-infos lib/
  1. Launch Claude Code in your Flutter project root where pubspec.yaml lives.

How It Works

Flutter uses the Dart analysis server as its LSP implementation. This server provides real-time type checking, code completion, and diagnostic information. While Claude Code does not directly connect to LSP servers as a client, you can leverage the analysis server indirectly through hooks and CLAUDE.md instructions.

When Claude edits Dart files, a post-edit hook runs dart analyze and feeds the results back. This gives Claude immediate feedback about type errors, missing imports, and deprecated API usage. Claude can then fix issues in a tight feedback loop without manual intervention.

CLAUDE.md plays a critical role here. By documenting your widget architecture, state management approach (Provider, Riverpod, BLoC), and naming conventions, Claude generates Flutter code that matches your project’s patterns. The LSP analysis then validates these changes against the actual type system.

Common Issues

dart analyze not found. Flutter bundles its own Dart SDK. Ensure flutter/bin is on your PATH, not just a standalone Dart installation. Run which dart to verify it points to the Flutter-bundled version.

Analysis server slow on large projects. The Dart analysis server loads your entire project on startup. For large monorepo Flutter projects, create an analysis_options.yaml that excludes generated files:

analyzer:
  exclude:
    - "**/*.g.dart"
    - "**/*.freezed.dart"
    - "build/**"

Claude generates code for wrong Flutter version. Specify your Flutter version and channel in CLAUDE.md. Flutter stable, beta, and master channels have different API surfaces, and Claude needs to know which one you are targeting.

Example CLAUDE.md Section

# Flutter Project

## Stack
- Flutter 3.24 (stable channel)
- Dart 3.5
- State management: Riverpod 2.x
- Navigation: go_router
- API: dio + retrofit

## Architecture
- lib/features/ — feature-based folder structure
- lib/core/ — shared widgets, theme, utils
- lib/data/ — repositories, models, data sources

## Rules
- All widgets must be const where possible
- Use riverpod code generation (@riverpod annotation)
- Run `dart analyze --fatal-infos` before any commit
- Run `flutter test` after modifying any widget
- Generated files: run `dart run build_runner build`
- Never manually edit .g.dart or .freezed.dart files

## Platform Notes
- iOS minimum: 15.0
- Android minimum SDK: 24
- Web: not supported in this project

Best Practices



I'm a solo developer in Vietnam. 50K Chrome extension users. $500K+ on Upwork. 5 Claude Max subscriptions running agent fleets in parallel. These are my actual CLAUDE.md templates, orchestration configs, and prompts. Not a course. Not theory. The files I copy into every project before I write a line of code. **[See what's inside →](https://zovo.one/lifetime?utm_source=ccg&utm_medium=cta-default&utm_campaign=claude-code-flutter-lsp)** $99 once. Free forever. 47/500 founding spots left.

Related Reading

Built by theluckystrike. More at zovo.one