4 min read

Flutter has got a large community with so many awesome people to help you. You search for anything and most likely you will find an open-source solution available on Github. But sometimes, when you clone the project, you may get a ‘Dart SDK is not configured’ error. This might happen because the project was certainly created in a different machine. So in this tutorial, we’ll see an easy and quick way to fix the error called Dart SDK is not Configured in Flutter which works in Windows, Linux, and Mac.

Here’s what we’ll cover:

How’s the Error Looks Like?

Here’s how the error looks like when you try to run the cloned project from Github.

dart sdk not configured error

Why Did you Get this Error?

This happened because you are trying to run a project which was not originally created in your machine. So probably the one who created the project might have a different Dart SDK path in his/her machine.

Steps to Fix Dart SDK is not Configured Error

To fix the Dart SDK is not Configured error, first of all, you must obtain the Flutter installation path and then figure out the dart SDK path. Then you can simply enable the Dart support for the project and let the Android Studio know about your Dart SDK path.

Here are the steps to fix the Error:

  1. Open the terminal (in Mac/Linux) or command prompt (Windows)
  2. Write which flutter. Copy the Flutter installation path.
  3. Open Android Studio,
    • For Windows/Linux: Go to File->Settings->Language & Framework->Dart.
    • For Mac: Click Android Studio on top -> Preferences -> Languages & Framework -> Dart.
  4. Checkmark the “Enable Dart support for the project…”
  5. In Dart SDK Path, enter the previously copied path and replace the flutter in the end with cache/dart-sdk. So it should look something like this /Users/pinkeshdarji/Data/Development/flutter/bin/cache/dart-sdk
  6. Click Apply.
  7. Click OK.
fixing dart sdk not configured error in flutter

Update dart sdk

To update Dart SDK, you can follow these steps:

  1. Open your terminal or command prompt.
  2. Check the current version of Dart SDK installed on your system by typing the following command:cssCopy codedart --version
  3. If a new version is available, you can download it from the official Dart website at https://dart.dev/get-dart.
  4. Once you have downloaded the new version, extract it to a suitable location on your system.
  5. Update your environment variables to point to the new version of the SDK. For example, on a Unix-based system, you can add the following line to your .bashrc or .bash_profile file:bashCopy codeexport PATH="$PATH:/path/to/dart-sdk/bin"
  6. Save the changes to the file and close it.
  7. Open a new terminal or command prompt window, and verify that the new version of Dart SDK is installed by typing the following command:cssCopy codedart --version

You should see the version number of the new SDK that you just installed.

If you’re struggling with Android app compatibility issues, check out our post on “Change Android Minsdkversion” for tips and tricks to make your app work seamlessly across different versions.

Upgrade dart sdk version in flutter

To upgrade the Dart SDK version used in a Flutter project, you can follow these steps:

  1. Check the current Dart SDK version used in your project by running the command dart --version in your project directory.
  2. If you have an older version of the Dart SDK, go to the Dart SDK downloads page and download the latest version for your operating system.
  3. After downloading the latest version of the Dart SDK, extract the archive file to a directory of your choice.
  4. Open your Flutter project in an IDE or code editor and update the Dart SDK path in your project configuration to point to the location where you extracted the new Dart SDK.
  5. Verify that the new Dart SDK is being used by running the command dart --version again in your project directory.

Note that upgrading the Dart SDK may also require upgrading the Flutter SDK, as they have specific version dependencies.

Conclusion

In this tutorial, we learned how to fix the Dart SDK is not Configured error in Flutter with a practical example. We also learned the cause of this error so that next time we know how to fix it. The solution works in Windows, Linux, and Mac machines.

FAQs

How to change dart sdk version in flutter?

To change the Dart SDK version in Flutter, you need to modify the environment section in the pubspec.yaml file of your project.

  1. Open the pubspec.yaml file in your code editor.
  2. Under the environment section, you will see the current version of the Dart SDK. It should look something like this:makefileCopy codeenvironment: sdk: ">=2.12.0 <3.0.0"
  3. Change the SDK version to the desired version. For example:makefileCopy codeenvironment: sdk: ">=2.14.0 <3.0.0"
  4. Save the pubspec.yaml file.
  5. In your terminal, navigate to the root directory of your project.
  6. Run the following command to upgrade the Dart SDK to the specified version:Copy codeflutter packages upgrade This command will update all of your project’s dependencies, including the Dart SDK, to the latest versions that are compatible with the version you specified in pubspec.yaml.
  7. Verify that the Dart SDK has been updated by running the following command:cssCopy codedart --version This command will display the current version of the Dart SDK that is installed on your system. If the version number matches the version you specified in pubspec.yaml, then you have successfully changed the Dart SDK version in your Flutter project.

How to find dart sdk path?

To find the path of the Dart SDK in your system, you can use the which command in your terminal or command prompt:

On Windows:

bashCopy codewhere dart

On macOS or Linux:

bashCopy codewhich dart

This will output the path of the Dart SDK.

How to configure dart sdk in android studio?

To configure Dart SDK in Android Studio, follow these steps:

  1. Download and install the Dart SDK from the official website.
  2. Open Android Studio and go to Preferences/Settings -> Languages & Frameworks -> Dart.
  3. Click on the “…” button next to “Dart SDK path”.
  4. Browse to the location where you installed the Dart SDK and select the dart-sdk folder.
  5. Click “Apply” and then “OK” to save the changes.

Once you have configured the Dart SDK in Android Studio, you can create new Flutter projects or open existing ones and start writing Dart code.

Would you like to check other interesting Flutter tutorials?