如何查找Flutter SDK路径、配置Flutter SDK及定位SDK文件位置?
Hey there! Let’s break down how to find, configure, and locate your Flutter SDK step by step—super straightforward once you know where to look.
First up, let’s track down where your Flutter SDK lives, since it varies a bit by operating system:
On Windows
- If you downloaded Flutter manually: It’s exactly the folder you extracted the ZIP archive to. Common spots are
C:\src\flutterorC:\flutter, but it could be anywhere you chose during extraction. - If you used Chocolatey to install: The default path is usually
C:\ProgramData\Chocolatey\lib\flutter\tools\flutter - Quick terminal check: Open Command Prompt and run
where flutter—this will spit out all paths where the flutter executable lives. The parent folder of that executable (the one abovebin) is your SDK root.
On macOS or Linux
- Manual download: It’s the folder you unzipped the tar.gz file into. Popular choices are
~/development/flutter(in your user directory) or/usr/local/flutter(a system-wide spot). - Homebrew install (macOS): For Apple Silicon, it’s typically
/opt/homebrew/Caskroom/flutter/<your-flutter-version>/flutter; for Intel Macs,/usr/local/Caskroom/flutter/<your-flutter-version>/flutter - Terminal shortcut: Run
which flutter—the output will look like/path/to/flutter/bin/flutter. Just strip off the/bin/flutterpart, and you’ve got your SDK root path.
This step makes sure your system can run Flutter commands from any terminal or IDE window, no matter where you are.
Windows
- Open System Properties: Right-click "This PC" → select "Properties" → click "Advanced system settings"
- Hit the Environment Variables button
- Under "System Variables", find the
Pathentry and click Edit - Add a new line with your Flutter SDK’s
binfolder path (e.g.,C:\src\flutter\bin) - Click "OK" all the way through to save changes. Restart your terminal or IDE for the changes to kick in.
macOS/Linux
- Open your shell’s config file in a text editor:
- For Bash users:
nano ~/.bash_profileornano ~/.bashrc - For Zsh users (most modern Macs):
nano ~/.zshrc
- For Bash users:
- Add this line at the end (replace
/path/to/flutterwith your actual SDK root path):export PATH="$PATH:/path/to/flutter/bin" - Save the file (press Ctrl+O, then Enter) and exit (Ctrl+X)
- Run
source ~/.zshrc(or the corresponding file for your shell) to apply changes right away, or just restart your terminal.
If you’re using an IDE for Flutter development, you’ll need to point it to your SDK path (or verify it’s already set):
Android Studio
- Open Android Studio, then go to File → Settings (on macOS, it’s Android Studio → Settings)
- Navigate to Languages & Frameworks → Flutter
- The "Flutter SDK path" field shows the current path. If it’s blank or wrong, click the folder icon to browse and select your SDK root folder. Hit "Apply" to save.
VS Code
- Open VS Code, go to File → Preferences → Settings (macOS: Code → Settings → Settings)
- Search for
Flutter SDK Pathin the settings search bar - Click "Edit in settings.json" and add this line (replace with your actual path):
"dart.flutterSdkPath": "/path/to/flutter", - Save the file, and restart VS Code if needed to apply the change.
Once you’ve got everything set up, open a brand new terminal and run:
flutter doctor
This command will check if your SDK is properly configured, and flag any missing dependencies or setup issues. If it shows no red errors, you’re ready to build Flutter apps!
内容的提问来源于stack exchange,提问作者praveen harikrishna




