You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter安装后Dart版本显示1.24.3而非2.x的问题求助

Fixing Mismatched Dart Version After Flutter Upgrade

Hey there! I’ve run into this exact issue before—let’s break down what’s happening and how to fix it.

Why the Version Mismatch?

The problem boils down to two separate Dart installations on your system:

  1. An old standalone Dart SDK located at /usr/local/bin/dart—this is the one your terminal is currently picking up
  2. The Flutter-bundled Dart SDK that came with your Flutter upgrade (the 2.x version you see in flutter --version)

When you run dart --version, your shell uses the first dart executable it finds in your PATH environment variable. Right now, /usr/local/bin is listed before Flutter’s bin directory, so it’s grabbing the outdated version instead of Flutter’s newer one.

How to Fix It

Follow these steps to prioritize Flutter’s Dart SDK:

  1. Open your shell configuration file

    • For Zsh (default on newer macOS), edit ~/.zshrc
    • For Bash, edit ~/.bash_profile or ~/.bashrc
  2. Adjust your PATH order
    Look for lines that set your PATH. Make sure the path to your Flutter bin directory comes before /usr/local/bin. For example, if Flutter is installed in your home folder:

    # Put Flutter's bin directory first
    export PATH="$HOME/flutter/bin:$PATH"
    # Then other system paths like /usr/local/bin
    export PATH="/usr/local/bin:$PATH"
    
  3. Refresh your shell environment
    Run this command to apply the changes immediately (replace with your config file if needed):

    source ~/.zshrc
    
  4. Verify the fix

    • Run where dart again—you should see Flutter’s Dart path listed first
    • Run dart --version; it should now match the Dart version shown in flutter --version

Alternative Option (If You Don’t Need Standalone Dart)

If you don’t use the standalone Dart SDK for any other projects, you can simply delete the old executable:

rm /usr/local/bin/dart

This will force your shell to use Flutter’s bundled Dart by default.

内容的提问来源于stack exchange,提问作者Chris G.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:08:40