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?
- Why Did you Get this Error?
- Steps to Fix Dart SDK is not Configured Error
- Update dart sdk
- Upgrade dart sdk version in flutter
How’s the Error Looks Like?
Here’s how the error looks like when you try to run the cloned project from Github.
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:
- Open the terminal (in Mac/Linux) or command prompt (Windows)
which flutter. Copy the Flutter installation path.
- Open Android Studio,
- For Windows/Linux: Go to File->Settings->Language & Framework->Dart.
- For Mac: Click Android Studio on top -> Preferences -> Languages & Framework -> Dart.
- Checkmark the “Enable Dart support for the project…”
- In Dart SDK Path, enter the previously copied path and replace the
flutterin the end with
cache/dart-sdk. So it should look something like this
- Click Apply.
- Click OK.
Update dart sdk
To update Dart SDK, you can follow these steps:
- Open your terminal or command prompt.
- Check the current version of Dart SDK installed on your system by typing the following command:cssCopy code
- If a new version is available, you can download it from the official Dart website at https://dart.dev/get-dart.
- Once you have downloaded the new version, extract it to a suitable location on your system.
- 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 code
- Save the changes to the file and close it.
- 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 code
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:
- Check the current Dart SDK version used in your project by running the command
dart --versionin your project directory.
- 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.
- After downloading the latest version of the Dart SDK, extract the archive file to a directory of your choice.
- Open your Flutter project in an IDE or code editor and update the
Dart SDK pathin your project configuration to point to the location where you extracted the new Dart SDK.
- Verify that the new Dart SDK is being used by running the command
dart --versionagain in your project directory.
Note that upgrading the Dart SDK may also require upgrading the Flutter SDK, as they have specific version dependencies.
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.
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.
- Open the
pubspec.yamlfile in your code editor.
- Under the
environmentsection, you will see the current version of the Dart SDK. It should look something like this:makefileCopy code
environment: sdk: ">=2.12.0 <3.0.0"
- Change the SDK version to the desired version. For example:makefileCopy code
environment: sdk: ">=2.14.0 <3.0.0"
- Save the
- In your terminal, navigate to the root directory of your project.
- Run the following command to upgrade the Dart SDK to the specified version:Copy code
flutter packages upgradeThis 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
- Verify that the Dart SDK has been updated by running the following command:cssCopy code
dart --versionThis 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 macOS or Linux:
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:
- Download and install the Dart SDK from the official website.
- Open Android Studio and go to Preferences/Settings -> Languages & Frameworks -> Dart.
- Click on the “…” button next to “Dart SDK path”.
- Browse to the location where you installed the Dart SDK and select the dart-sdk folder.
- 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?
Great content! Keep up the good work!
Oh my goodness! Amazing article dude! Thank you so
much, However I am having issues with your RSS. I don’t know why I am unable
to join it. Is there anybody having similar RSS problems?
Anybody who knows the answer can you kindly respond?
WOW just what I was searching for. Came here by searching for a