Dart 的 SDK 位于/flutter 文件夹的哪个位置?

软件

MacOS Sierra 10.12.6
Android Studio 3.1.2
Flutter 0.3.2 • channel beta
Tools • Dart 2.0.0-dev.48.0.flutter-fe606f890b
Flutter doctor (no problems found)

问题

根据文档,当 Flutter 被下载时,Dart 的 SDK 应该是捆绑在一起的:

Dart SDK 与 Flutter 绑定,无需单独安装 Dart

然而,我用 Android Studio 打开了一个现有的 Flutter 项目,它建议我使用“ 下载 Dart SDK”或“ 打开 Dart 设置”:

Image of Android Studio suggesting to "download Dart SDK"

显然,我需要“ 打开 Dart 设置”并告诉 Android 工作室在哪里可以找到飞镖的 SDK。但是,在 flutter/目录中找不到它。

80573 次浏览

The Dart SDK lives inside the bin/cache/dart-sdk folder of the Flutter SDK. It will be downloaded the first time you run the flutter command, so may not exist if you've not yet run flutter.

The Dart's SDK is located at /flutter/bin/cache/dart-sdk

However, If Android Studio's flutter plugin is installed, the plugin needs to be told where flutter's SDK is located. Android Studio should be able to locate Dart's SDK afterwards:

enter image description here

If you installed Dart on Windows via Chocolatey, you will find it on C:\tools\dart-sdk

I have faced this issue,

  1. Go to the folder where you have downloaded flutter and then delete the flutter folder.

  2. Go to your download folder and where you have downloaded the flutter the first time.

  3. Extract this file again where you have deleted the flutter...

This is working for me.

After installing flutter however you choose.

  1. run the following command

flutter sdk-path

  1. In Android-Studio select File->Setting->Languages & Frameworks->Flutter (assuming you have installed teh flutter plugin)

  2. Populate the "Flutter SDK path:" with the result from (1).

  3. Click apply. The Dart SDK should automatically get populated.

For my installation the values are:

Flutter SDK path: /home/andrew/snap/flutter/common/flutter

Dart SDK path: /home/andrew/snap/flutter/common/flutter/bin/cache/dart-sdk

I have downloaded flutter sdk via homebrew

For Mac OS: 10.14.5

Android Studio version : Arctic Fox 2020.3.1

Flutter sdk location is /usr/local/Caskroom/flutter/2.5.0/flutter

Dart location: /usr/local/Caskroom/flutter/2.5.0/flutter/bin/cache/dart-sdk

Run brew info flutter

Then you get the path: e.g. /opt/homebrew/Caskroom/flutter/2.5.3

And there the bin/cache has the dartk-sdk:

/opt/homebrew/Caskroom/flutter/2.5.3/flutter/bin/cache/dart-sdk

Everyone that is still searching for the correct answer should checkout this answer https://stackoverflow.com/a/63409260/9823820.

If you have the flutter SDK installed.

Run:

flutter doctor -v

The first line will show the install path.

Credits go to @Lee Higgins

Sometimes it is the build directory that he cannot create, suddenly devtools crashes, you can simply recreate it in $HOME/.pub-cache/hosted/pub.dartlang.org/devtools-your-version, then give it the right rights with for example sudo chown -R $USER:$USER $HOME/.pub-cache/hosted/pub.dartlang.org/devtools-your-version/build after re-creating the build directory

Check this:

brew info dart

Output:

Please note the path to the Dart SDK: /opt/homebrew/opt/dart/libexec

If someone is looking for the path to flutter sdk in Linux I found mine here

/home/your_username/flutter/common/flutter/ flutter path /home/your_username/flutter/common/flutter/bin/cache/dart-sdk dart path