Flutter

Claude Code Flutter Test: 48 Runs, One Deprecated API Written

Table of Contents

This post is for Flutter developers who use Claude Code, or are about to, and keep hearing that AI agents write outdated Flutter. The complaint is specific and old: a 2025 forum thread says the models “still use a lot of deprecated code, such as MediaQuery.of(context).size … or WillPopScope instead of PopScope”. Nobody has counted it since. So this post runs Claude Code on Flutter 3.50.1, 48 times, on eight everyday screen tasks, with and without the official dart-flutter plugin, and scores every result with flutter analyze and flutter test. You get the counts, the one deprecated API that did show up, the failure that actually matters, and a clear answer on whether the plugin is worth its context cost.

The results in this post came from this environment:

Measured 2026-12-02
Windows 11 Pro 25H2 (build 26200), AMD Ryzen 5 8600G (6C/12T), 16 GB RAM
Flutter 3.50.1 stable (framework ae9b586f34, 2026-11-18), Dart 3.14.0, material_ui 1.1.0
Claude Code 2.1.332, model claude-opus-5-5, headless (-p) with stream-json output
dart-flutter plugin 1.0.7 (flutter/agent-plugins commit ff6d472, 2026-11-18), dart mcp-server 1.2.2
8 prompts x 2 conditions x 3 repeats = 48 runs, each from a fresh copy of the same project
Raw data: data/claude-code-flutter-apis-2026-12-02.tsv in the publisher repo

Every run is reported, not only an average. Medians are given where a number varies, with the minimum and maximum next to them. The dollar figures are the list-price estimate Claude Code prints for each session; the runs themselves went through a subscription.

Claude Code Flutter Results: The Short Answer

Here is the scorecard across all 48 runs, split by condition. “Bare” is Claude Code with no Flutter tooling. “Plugin” adds the official dart-flutter plugin, which brings the Dart MCP server and 25 Flutter and Dart skills.

MetricBare (24 runs)Plugin (24 runs)
Analyzer errors, warnings, infos at the end0, 0, 00, 0, 0
Deprecated APIs left in the final code00
Deprecated APIs written at any point01 (cacheExtent, fixed in the same run)
Runs whose test suite passes afterwards19 of 2419 of 24
Runs left with the stale template test failing53
Runs left with the agent’s own tests failing02
Median wall time per run67 s (30 to 82)61 s (31 to 116)
Median turns15 (9 to 20)15.5 (10 to 22)
Median list cost per run$0.347 (0.241 to 0.423)$0.405 (0.273 to 0.600)
Context tokens on the first call39,05242,401

Three findings stand out. First, the deprecated API problem is gone for this model and this SDK: 48 runs, eight tasks chosen to provoke known deprecations, and the only deprecated member ever written was caught and removed by the agent before it finished. Second, the real failure is tests, not APIs. In 8 runs the agent rewrote the home screen and never touched the template’s counter test, which then failed. Third, the plugin made no measurable difference to code quality on these tasks, while costing a median 17% more per run and about 3,350 extra context tokens on every call.

One caveat shapes the test numbers, and it is covered in full below: the harness denied 144 tool calls, mostly PowerShell commands the agent chose on Windows. The analyzer results hold regardless; the plugin versus bare comparison on tests does not.

How the Test Works: Eight Prompts Built to Trip Old APIs

Each prompt targets a Flutter area where deprecated APIs are common in older tutorials and training data. The project is a fresh flutter create app on 3.50.1, already switched to package:material_ui, which is how a new 3.50 project looks after the material and cupertino split.

PromptTaskDeprecated APIs it invites
p1Edit profile form with an unsaved changes dialog on backWillPopScope, PopScope.onPopInvoked
p2Product card with a gradient overlay and a 15% opacity badgeColor.withOpacity, Color.value, Color.red
p3Light and dark themes from a seed color, with a toggleColorScheme.background, surfaceVariant, headline6
p4Responsive grid and a title capped at 1.3x text scaletextScaleFactor, MediaQuery.of(context).size
p5go_router with a path parameter and a login redirectgo_router signatures from 13 or earlier
p6Riverpod cart and an async product listStateNotifier, StateProvider
p7Checkout form with dropdown, radios and a switchDropdownButtonFormField.value, Radio.groupValue, Switch.activeColor
p8Keyboard navigation for a desktop listRawKeyboardListener, RawKeyEvent

Before any agent ran, a probe file using all of those old APIs went through the analyzer. It reported 22 issues, so the scoring catches every pattern above. Notably, headline6 is no longer a deprecation but a hard error, because it has been removed.

Each run starts from a fresh copy of the base project and sends one prompt in headless mode. The agent may edit files and run flutter and dart commands. After it finishes, the harness runs flutter pub get, flutter analyze and flutter test itself, so the score never depends on what the agent claims. Here is the core of the harness:

#!/usr/bin/env bash
# One run: fresh copy, one prompt, then score with the analyzer.
set -u
W=/c/development/claude-flutter-apis
CL="$(ls -d ~/.vscode/extensions/anthropic.claude-code-*-win32-x64 | sort -V | tail -1)/resources/native-binary/claude.exe"
export PATH="/c/development/flutter-3.50.1/flutter/bin:$PATH"
export ENABLE_CLAUDEAI_MCP_SERVERS=false        # no claude.ai connectors in either condition
SUFFIX=" Keep the code in lib/. When you are done the project should compile."

one_run() {
  local prompt=$1 cond=$2 dir=$3
  rm -rf "$dir"; cp -r "$W/base" "$dir"; cd "$dir" || return 1
  local extra=()
  [ "$cond" = plugin ] && extra=(--plugin-dir "$W/agent-plugins")
  "$CL" -p "$prompt$SUFFIX" --model claude-opus-5-5 \
    --output-format stream-json --verbose \
    --setting-sources project --permission-mode acceptEdits \
    --allowedTools "Bash(flutter:*)" "Bash(dart:*)" \
      "mcp__plugin_dart-flutter_dart-mcp-server" "Skill" \
    "${extra[@]}" > transcript.jsonl 2> stderr.txt
  flutter pub get > pubget.txt 2>&1
  flutter analyze --no-fatal-infos --no-fatal-warnings > analyze.txt 2>&1
}

Two flags matter here. --setting-sources project keeps the operator’s own user settings, hooks and memory out of the runs, so both conditions start from the same Claude Code defaults. Meanwhile, --plugin-dir loads the plugin from a pinned clone rather than a marketplace install, so the plugin version cannot drift mid-batch.

Does Claude Code Write Deprecated Flutter APIs?

No, not on these tasks. Across 48 runs, Claude Code wrote one deprecated Flutter API, and the final code contained none. That one was cacheExtent on a ListView.builder in a p8 plugin run. Flutter deprecated it after 3.41 in favor of scrollCacheExtent. The plugin’s analyze_files tool flagged it, and the agent removed the line before finishing.

The final analyzer output looked the same in every one of the 48 projects:

$ flutter analyze --no-fatal-infos --no-fatal-warnings
Analyzing p7-plugin-2...
No issues found! (ran in 1.2s)

The usage tells the story better than the zero does. For instance, the back-handling prompt produced PopScope with the newer result-aware callback in every run, not WillPopScope:

import 'package:material_ui/material_ui.dart';

// Adapted from p1-bare-1 (form body moved to a helper): block the pop
// while the form is dirty, then ask.
@override
Widget build(BuildContext context) {
  return PopScope<Object?>(
    canPop: !_hasUnsavedChanges,
    onPopInvokedWithResult: (didPop, result) async {
      if (didPop) return;
      final navigator = Navigator.of(context);
      final shouldLeave = await _confirmDiscard();
      // Navigator.pop bypasses canPop, so this leaves the screen.
      if (shouldLeave && mounted) navigator.pop(result);
    },
    child: Scaffold(
      appBar: AppBar(title: const Text('Edit Profile')),
      body: _buildForm(),
    ),
  );
}

This works because canPop: false makes the route refuse the system back gesture, and the callback then decides. Capturing the navigator before the await also avoids using context across an async gap, which is exactly the lint a careless version trips.

Similarly, the checkout prompt used the RadioGroup ancestor that replaced per-radio groupValue in Flutter 3.32, rather than the older pattern:

import 'package:material_ui/material_ui.dart';

enum ShippingSpeed { standard, express, overnight }

// Adapted from p7-bare-1 (enum label simplified to .name): the group owns
// the value, each tile only declares its own.
RadioGroup<ShippingSpeed>(
  groupValue: _shippingSpeed,
  onChanged: (value) {
    if (value != null) setState(() => _shippingSpeed = value);
  },
  child: Column(
    children: [
      for (final speed in ShippingSpeed.values)
        RadioListTile<ShippingSpeed>(
          value: speed,
          title: Text(speed.name),
          contentPadding: EdgeInsets.zero,
        ),
    ],
  ),
)

The rest followed the same pattern. Opacity went through withValues(alpha: 0.15) in all six p2 runs. Text scaling used MediaQuery.textScalerOf(context) and TextScaler.clamp, never textScaleFactor. Keyboard handling took three different current routes across six runs, Shortcuts with Actions, CallbackShortcuts, and Focus with onKeyEvent, and never RawKeyboardListener. In addition, MediaQuery.of(context).size, the forum’s other example, did not appear in any final project; the responsive prompt used LayoutBuilder instead.

Package Versions: go_router 18 and Riverpod 3.5, Every Time

The package prompts are where training data goes stale fastest, because the agent has to pick a version. In all twelve runs of p5 and p6, it ran flutter pub add instead of typing a version into pubspec.yaml. As a result, every routing run landed on go_router: ^18.1.5 and every state management run on flutter_riverpod: ^3.5.0, the current releases on the day.

The Riverpod code matched the version. All six p6 runs used Notifier with NotifierProvider, and none used StateNotifier or StateProvider, which moved to a legacy import in Riverpod 3. If you maintain an older go_router app, the go_router 13 to 18 upgrade walkthrough shows what changes at each major version, which is the part an agent would have to get right on an existing codebase.

Where the Knowledge Came From: Source Lookups

Part of the explanation is that the agent checks. In 27 of 48 runs it tried to read the installed Flutter SDK or the package sources before or while writing. In bare runs that meant grep over the SDK or the pub cache; in plugin runs it meant the MCP server’s read_package_uris and rip_grep_packages tools.

ConditionRuns that looked up SDK or package sourceMCP tool calls (distinct)
Bare12 of 24none
Plugin15 of 2427 analyze_files, 12 read_package_uris, 11 rip_grep_packages, 6 pub, 2 roots

However, lookups do not explain the whole result. In the 21 runs that never looked anything up, the agent still wrote zero deprecated APIs. Many shell lookups were also denied by the harness, as the next section shows. So for these eight tasks, the model’s own knowledge of current Flutter was enough.

The Permission Problem That Shaped the Test Results

The harness allowed Bash(flutter:*) and Bash(dart:*). On Windows, though, Claude Code also has a PowerShell tool, and the agent used it often. A rule for one tool does not cover the other, so flutter test sent through PowerShell was denied even though the same command through Bash was allowed.

ConditionDenied tool callsOf which PowerShellRuns with a flutter command deniedRuns with flutter test deniedRuns that ran tests through Bash
Bare925121 of 24414
Plugin523916 of 24117

The other denials were reads outside the project: Read, Grep and shell grep against the SDK and the pub cache. Every one of the 48 runs hit at least one denial.

This matters for interpretation. The analyzer result is unaffected, because the agent could always analyze through Bash or the MCP server, and the harness re-ran the analyzer independently anyway. The test comparison between conditions is not clean, however. Plugin runs had flutter test blocked far more often, so “19 of 24 pass” in both columns does not prove the plugin is neutral on tests. The two plugin runs that ended with their own tests failing were both runs where flutter test was denied. Both agents said so in their final report, for example:

I added the checkout screen in `lib/checkout_screen.dart`. The Dart analyzer finds
no errors or warnings across the project. I couldn't run the tests (`flutter test`
needed permission it didn't get) and didn't launch the app, so nothing has been run yet.

That honesty is useful, but only if someone reads the report. In practice, a headless pipeline that checks only the exit code would merge this.

The Real Failure: Stale Template Tests

The failure that does not depend on permissions is the counter test. A new Flutter project ships test/widget_test.dart, which taps a + button and expects the counter to read 1. Several prompts replaced the home screen. In 8 of 48 runs the agent did so and left that test alone, and it never attempted flutter test:

$ flutter test
00:00 +0 -1: Counter increments smoke test [E]
  Expected: exactly one matching candidate
    Actual: _TextWidgetFinder:<Found 0 widgets with text "0": []>
  Test failed. See exception logs above.
RunPromptConditionTried flutter test
p2-bare-3Product cardsBareNo
p2-plugin-1Product cardsPluginNo
p2-plugin-3Product cardsPluginNo
p5-bare-2go_routerBareNo
p5-bare-3go_routerBareNo
p8-bare-1Keyboard listBareNo
p8-bare-2Keyboard listBareNo
p8-plugin-1Keyboard listPluginNo (tried a Windows build, denied)

Meanwhile, the agent did handle tests well when it engaged with them. In 37 of 48 runs it wrote or edited a test file, often without being asked. The p4 runs, for example, added widget tests that pin the window size and the text scale to check the three breakpoints and the 1.3x cap. The prompt’s final sentence asked only that the project “should compile”, and the agent treated the analyzer as the finish line. That is the pattern the guide to reviewing AI-written code warns about: compiling is not the same as working.

Is the Dart and Flutter Plugin Worth It?

Not for one-screen tasks like these, at least not by any measure here. Code quality was identical: zero analyzer issues in both conditions, and the one deprecated API slip happened in a plugin run. The plugin’s skills fired in only one place. All three go_router runs loaded flutter-setup-declarative-routing, and those runs were the slowest and most expensive p5 runs, with a median 21 turns against 16 for bare.

On the other side of the ledger, the plugin adds about 3,350 tokens to every request before the prompt is read, because its tools and skill list ride along in context. Across these runs that showed up as a median $0.405 per run against $0.347, about 17% more. The Flutter MCP server documentation promises “real-time access to analyzer diagnostics, symbol resolution, test runners, and runtime inspection”. Those capabilities are real, but none of these tasks needed a running app, which is where the MCP server has tools that bare Claude Code lacks. If you are new to MCP in Claude Code, the Claude Code MCP servers guide covers the setup and the context cost of each server.

One more detail: the plugin also ships dart format and dart analyze hooks, but in .agents/hooks.json, a cross-agent format. Claude Code did not load them in these runs, so no hook ran in either condition.

When to Use Claude Code for Flutter Work

  • New screens and widgets on a current SDK, where the analyzer can confirm the result
  • Adding a package, provided the agent runs flutter pub add and picks up the current version
  • Replacing deprecated APIs in an existing codebase, since it writes the replacements correctly without being told
  • Drafting widget tests for layout rules, such as breakpoints and text scale caps

When NOT to Rely on Claude Code Alone

  • Any change that replaces a screen another test depends on, unless the test suite runs as part of the task
  • Headless or CI pipelines where nobody reads the agent’s final report
  • Tasks that need a running app, such as hot reload checks, where bare Claude Code has no runtime access
  • Older Flutter versions or old package pins, which this test did not cover

Common Mistakes with Claude Code on Flutter Projects

  • Treating “no issues found” from the analyzer as done, when the counter test still fails
  • Writing allow rules for Bash only on Windows, so PowerShell commands are silently denied
  • Installing the dart-flutter plugin for every session, paying about 3,350 tokens per request on tasks that never use it
  • Asking only that the project “should compile”, which the agent reads as the finish line
  • Trusting old forum advice about deprecated APIs without checking it against the current model

Real-World Scenario: An Agent Feature Branch in a Small Team

Consider a small team maintaining a mid-sized Flutter app with 20 to 30 screens. They start giving Claude Code one screen per task over a few weeks. Based on these runs, the code review will rarely catch a deprecated API, because there will rarely be one. Instead, the problem shows up in CI: a feature branch replaces the home screen, the analyzer is green, and the old smoke test fails on the pipeline.

The trade-off is cheap to fix. Add “run flutter analyze and flutter test, and update any test your change breaks” to the prompt or to the project’s CLAUDE.md, and allow both commands for every shell the agent can use on that OS. The test coverage after AI post covers what to measure once agents write tests as well as code. The other lesson is to read the agent’s final message: in both plugin runs that ended with failing tests, the agent had already said the tests did not run.

What This Test Did Not Cover

Several limits apply, and each one could change the result:

  • One model. All runs used Claude Opus 5.5. Smaller or older models may write more deprecated code, and this table goes stale when the model changes.
  • One SDK, already migrated. The base project imported material_ui. On a project still importing package:flutter/material.dart, the agent may follow the existing import, which 3.50 reports as deprecated. That was not tested.
  • Greenfield screens. Every task added new code. Migrating existing deprecated code is a different job.
  • Permissions. The 144 denials above skew the test comparison between conditions. The bare and plugin test numbers should not be read as a plugin effect.
  • Windows only. The PowerShell behavior is Windows-specific. On macOS or Linux, the Bash allow rule would have covered every command.
  • Three repeats per cell. That is enough to show spread, not to detect small differences in cost or turns.

Conclusion

On Flutter 3.50.1, Claude Code on Opus 5.5 no longer writes the deprecated Flutter APIs people complain about: one slip in 48 runs, caught and fixed by the agent itself. The weak spot is tests. Eight runs left a broken template test because the agent never ran the suite, and on Windows the allow rules decide whether it can. The official plugin did not improve any score here and cost about 17% more per run. So for everyday Claude Code Flutter work, skip the plugin for single-screen tasks, put flutter test in the instructions, and allow it for every shell. Next, check what changed in your own SDK upgrade path with the Flutter breaking changes by release tracker, or the material and cupertino package migration if your app still imports the framework copies.