You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何查找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.

Finding Your Flutter SDK Path

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\flutter or C:\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 above bin) 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/flutter part, and you’ve got your SDK root path.
Configuring the Flutter SDK (Setting Environment Variables)

This step makes sure your system can run Flutter commands from any terminal or IDE window, no matter where you are.

Windows

  1. Open System Properties: Right-click "This PC" → select "Properties" → click "Advanced system settings"
  2. Hit the Environment Variables button
  3. Under "System Variables", find the Path entry and click Edit
  4. Add a new line with your Flutter SDK’s bin folder path (e.g., C:\src\flutter\bin)
  5. Click "OK" all the way through to save changes. Restart your terminal or IDE for the changes to kick in.

macOS/Linux

  1. Open your shell’s config file in a text editor:
    • For Bash users: nano ~/.bash_profile or nano ~/.bashrc
    • For Zsh users (most modern Macs): nano ~/.zshrc
  2. Add this line at the end (replace /path/to/flutter with your actual SDK root path):
    export PATH="$PATH:/path/to/flutter/bin"
    
  3. Save the file (press Ctrl+O, then Enter) and exit (Ctrl+X)
  4. Run source ~/.zshrc (or the corresponding file for your shell) to apply changes right away, or just restart your terminal.
Locating Flutter SDK in IDEs (Android Studio/VS Code)

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

  1. Open Android Studio, then go to File → Settings (on macOS, it’s Android Studio → Settings)
  2. Navigate to Languages & Frameworks → Flutter
  3. 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

  1. Open VS Code, go to File → Preferences → Settings (macOS: Code → Settings → Settings)
  2. Search for Flutter SDK Path in the settings search bar
  3. Click "Edit in settings.json" and add this line (replace with your actual path):
    "dart.flutterSdkPath": "/path/to/flutter",
    
  4. Save the file, and restart VS Code if needed to apply the change.
Verifying Your Setup

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

火山引擎 最新活动