Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the current Dart SDK version?

Tags:

flutter

dart

I ran the following commands in my foo project:

iDecode@iDecodes-Mac foo % pub get
Resolving dependencies... 
The current Dart SDK version is 2.7.2.

Because foo requires SDK version >=2.12.0 <3.0.0, version solving failed.
iDecode@iDecodes-Mac foo % flutter --version
Flutter 2.6.0-11.0.pre • channel dev
Tools • Dart 2.15.0 (build 2.15.0-116.0.dev)

My pubspec.yaml file has:

environment:
  sdk: '>=2.12.0 <3.0.0'

As you can see my current Dart SDK version is set to 2.7.2, my project is targeting a min of 2.12.0 and Dart SDK installed on my machine is 2.15.0. So, how do I change the current Dart SDK version?

This is my ~/.zshrc file

export PATH=/flutter/bin:$PATH
export PATH=$PATH:/$HOME/Library/Android/sdk/platform-tools/
export PATH="$PATH:/$HOME/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
like image 762
iDecode Avatar asked Dec 20 '25 05:12

iDecode


1 Answers

It seems like you installed Flutter/Dart SDK somewhere using Homebrew. Use which flutter and which dart to see the actual Flutter/Dart command that is taking effect. Once you find where your Dart SDK is you can use

brew uninstall dart

After this when you run which dart it will now point to where your Flutter SDK was installed.

like image 87
ch271828n Avatar answered Dec 23 '25 10:12

ch271828n



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!