What's New in Dart 3.9: Faster Tools, Smarter Analysis, and AI Integration

Smarter Null-Safety Analysis

Dart 3.9 enhances type promotion, reachability, and definite assignment with deeper null-safety awareness. This results in more accurate warnings for dead code and redundant null checks. To enable these improvements, set your SDK constraint:

# pubspec.yaml
environment:
  sdk: ^3.9.0

Here’s a quick example where the analyzer now catches an unreachable branch:

int? n;
if (n == null) return;
// n is guaranteed to be non-null below, so the extra 'if' is highlighted:
if (n != null) print(n.isEven); // dead_code / redundant check
print(n.isEven);

Faster Command-Line Interface (CLI)

Commands like dart analyze and dart fix now run from an AOT (Ahead-Of-Time) snapshot of the analysis server, eliminating JIT compilation for each call. On real-world packages, dart analyze is now up to 1.5x faster, with even more significant speed-ups for shorter commands.

Official MCP Server for AI Assistant Integration

The new Dart and Flutter MCP Server acts as a bridge between your project and compatible AI assistants like Gemini CLI, GitHub Copilot, and Cursor. It provides secure access to your project's context, enabling assistants to perform actions like fixing errors, managing dependencies, and running tests. This feature is experimental and requires Dart 3.9+.

To start the server for a compatible client, run:

# The MCP server command is 'dart mcp-server'
dart mcp-server

More Precise Dependency Management with Pub

  • Git Tag Resolution: You can now resolve Git dependencies using tags via tag_pattern, which is perfect for versioned releases like vX.Y.Z.
  • Flutter Version Pinning: Pub now respects the upper bound for the flutter SDK in your root package. This allows you to pin your project to a specific Flutter version, causing pub get to fail if the SDKs don't match.
# pubspec.yaml — example of git + tag_pattern and a strict Flutter pin
environment:
  sdk: ^3.9.0
  flutter: 3.35.0

dependencies:
  my_dependency:
    git:
      url: https://github.com/example/my_dependency
      tag_pattern: v{{version}}
    version: ^2.0.1

Compiler Updates: Cross-Compilation and Architectures

Dart now supports cross-compilation on Linux for ARM32 and RISC-V64 architectures, with improved documentation for dart compile. Concurrently, 32-bit x86 support is now deprecated, mainly affecting older emulators.


What This Means for Your Team

  1. Fewer Hidden Bugs: Enhanced null-safety analysis catches dead code and redundant checks during the analyze step, simplifying code reviews and reducing regressions.
  2. Faster Development Cycles: The AOT snapshot for the analysis server reduces friction from frequent local checks (analyze, fix), a noticeable improvement in monorepos and large Flutter projects.
  3. More Predictable Dependencies: Using tag_pattern for Git dependencies prevents accidental commits from being used, while pinning the flutter version ensures the entire team works with the same SDK.
  4. Seamless AI Tool Integration: The MCP server provides a standardized way for AI assistants to understand your project and perform tasks like fixing runtime errors or suggesting packages, saving valuable time.
  5. Expanded Platform Support: Cross-compilation for Linux ARM and RISC-V64 opens up possibilities for edge computing and embedded systems. Note that 32-bit x86 is being phased out, so plan to update any legacy emulators.

Your Action Plan: A Checklist

  1. Update SDK Constraints: In pubspec.yaml, set sdk: ^3.9.0. Then run dart pub upgrade.
  2. Enable New Lints: Add switch_on_type and unnecessary_unawaited to your analysis_options.yaml. Run dart analyze and dart fix --apply.
  3. Benefit from Faster Tooling: Start using the new CLI binaries. Measure the performance gain in your repository with time dart analyze.
  4. Organize Git Dependencies: If you use version tags for releases, add the tag_pattern to the relevant entries in pubspec.yaml.
  5. Experiment with the MCP Server: If you use an AI assistant, configure it to launch dart mcp-server and test prompts like 'fix this layout error.'

Conclusion

Dart 3.9 is a practical update focused on saving you time and reducing noise in your codebase. With faster tooling, smarter null analysis, and more disciplined dependency management, it's a valuable upgrade. If you regularly use the Dart CLI, rely on Git dependencies, or are exploring ARM/RISC-V targets, updating now is highly recommended.