Sub topic 2
Installing the Flutter SDK
This chapter covers getting a working Flutter SDK onto your machine. You will download it, put it on your PATH, run it once, and confirm the result. The next chapter covers flutter doctor, which checks the rest of the toolchain (Android tooling, Xcode, Chrome).
This chapter assumes you are comfortable in a terminal. You should know what an environment variable is, how a shell finds executables, and the basics of Git.
What you are installing
The Flutter SDK is a directory, not a system-wide installer. It contains:
bin/flutterandbin/dart: launcher scripts that you put on yourPATH.packages/: the Flutter framework source, written in Dart.bin/cache/: downloaded artifacts, including the Dart SDK and the engine binaries. This directory is empty in a fresh download and is filled in on first run.
The Dart SDK is bundled. You do not install Dart separately, and dart on your PATH should come from inside the Flutter directory.
Because the SDK is a plain directory, you can keep several copies side by side and switch by changing PATH. Nothing is written to system locations.
Before you download
Check these items first. Most failed installs trace back to one of them.
| Platform | Needs before install |
|---|---|
| Windows | Git for Windows, PowerShell, and a folder path with no spaces or special characters |
| macOS | Command line tools (they provide `git`). On Apple silicon, Rosetta may be needed by some tools |
| Linux | `bash`, `curl`, `git`, `unzip`, `xz-utils`, `zip`, and `libglu1-mesa` |
Disk space is the other factor. Allow a few gigabytes for the SDK and its cache. The Android and iOS toolchains need much more, but those belong to later chapters.
On Debian or Ubuntu, install the Linux dependencies like this:
sudo apt-get update
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesaOn macOS, install the command line tools and, on Apple silicon, Rosetta:
xcode-select --install
sudo softwareupdate --install-rosetta --agree-to-licenseChoosing a channel
Flutter ships through channels. A channel is a Git branch of the Flutter repository.
| Channel | Purpose | Use it for |
|---|---|---|
| stable | Releases that passed the full validation process, updated roughly quarterly | Learning, production apps |
| beta | A monthly snapshot of upcoming changes | Trying features before release |
| main | The development head, with no stability guarantee | Contributing to Flutter |
Use stable unless you have a specific reason not to. Tutorials and package versions are written against it.
Method 1: Clone with Git
Cloning gives you a real Git checkout. It is the easiest approach to upgrade, switch channels, and pin to a version.
Pick a folder you own. Do not use C:\Program Files\ or /usr/local. Flutter writes to its own directory when it updates and caches artifacts, and a protected location causes permission errors.
mkdir -p "$HOME/development"
git clone https://github.com/flutter/flutter.git -b stable "$HOME/development/flutter"On Windows, run the same clone in PowerShell:
New-Item -ItemType Directory -Force "$env:USERPROFILE\development"
git clone https://github.com/flutter/flutter.git -b stable "$env:USERPROFILE\development\flutter"Method 2: Download the archive
The install page at docs.flutter.dev offers a .zip (Windows and macOS) or .tar.xz (Linux) for each release. Extract it into the same kind of user-owned folder. For example, on Linux:
mkdir -p "$HOME/development"
tar -xf ~/Downloads/flutter_linux_<version>-stable.tar.xz -C "$HOME/development"Replace <version> with the file name you downloaded. The archive method has no .git history that you can use to switch versions, so you re-download to move to a new release. On Apple silicon, pick the arm64 archive, not the x64 one.
Adding Flutter to your PATH
The flutter script lives in flutter/bin. Your shell finds it only if that directory is on PATH.
For zsh (the macOS default), append to ~/.zshrc:
echo 'export PATH="$HOME/development/flutter/bin:$PATH"' >> ~/.zshrcFor bash, use ~/.bashrc instead. Putting Flutter at the front of PATH makes sure its bundled dart wins over any other Dart installation.
On Windows, set a user-level variable so you do not need administrator rights:
$flutterBin = "$env:USERPROFILE\development\flutter\bin"
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
[Environment]::SetEnvironmentVariable("Path", "$userPath;$flutterBin", "User")A shell reads PATH when it starts. Edits do not affect terminals that are already open. Open a new terminal, or run source ~/.zshrc in the current one.
Confirm the shell finds the right copy:
which flutter
which dartOn Windows PowerShell, use where.exe flutter and where.exe dart. Both paths should point inside your Flutter directory.
First run
The first flutter command does extra work. The launcher script finds that the Dart SDK and engine artifacts are missing from bin/cache, downloads them, and then runs your command. Expect a pause and some progress output.
flutter --version
dart --versionThe output lists the Flutter version, the channel, the Git revision, the engine revision, and the Dart and DevTools versions. The Dart version is fixed by the Flutter release you installed. A given Flutter release always carries one Dart version.
The tool may also ask about sending anonymous usage and crash data. Choose whichever you prefer. You can change it later:
flutter config --no-analyticsManaging versions
A clone-based install can change channel or version in place.
flutter channel
flutter channel beta
flutter upgrade
flutter downgradeflutter channellists channels and marks the current one.flutter channel betaswitches branch. Runflutter upgradeafterward so the matching artifacts are downloaded.flutter upgradepulls the latest commit on your channel.flutter downgradereturns to the version you used before.
To pin an exact release, check out its tag in the clone:
cd "$HOME/development/flutter"
git checkout <version>
flutter --versionReplace <version> with a release tag, for example one you saw listed in flutter --version output on another machine. The version check forces the matching Dart SDK and artifacts to download. Teams that need different versions per project often use a version manager such as FVM. Each project then records its own Flutter version.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| `command not found: flutter` | `bin` is not on `PATH`, or the shell predates the edit | Check the path in your shell profile, then open a new terminal |
| `Waiting for another flutter command to release the startup lock...` | Another Flutter process is running, or a crashed one left a lock | Close other Flutter processes. If none exist, delete `bin/cache/lockfile` |
| `Permission denied` while updating or downloading | SDK is in a root-owned or protected folder | Move it to a folder you own, or fix its ownership |
| `fatal: detected dubious ownership in repository` | The clone is owned by a different user than the one running Git | Re-clone as your own user, or add the folder as a Git `safe.directory` |
| `Error: Unable to find git in your PATH` | Git is not installed or not on `PATH` | Install Git and open a new terminal |
| Downloads hang or fail on first run | Corporate proxy, firewall, or mirror needs | Set `HTTPS_PROXY`, or use a mirror via `PUB_HOSTED_URL` and `FLUTTER_STORAGE_BASE_URL` |
If dart or flutter resolves to an unexpected location, PATH order is the cause. A directory earlier in the list wins. Move the Flutter entry to the front.
What to expect next
At this point flutter --version works, but the SDK is only the framework and the command line tool. You cannot yet build for Android or iOS, because those SDKs are separate. The next chapter uses flutter doctor to find out exactly which pieces are missing for the platforms you care about.
Exercise
After editing ~/.zshrc to add the Flutter bin directory to PATH, you run flutter --version in the same terminal and get "command not found". The line in the file is correct. What are two ways to fix it, and why does the problem happen?
Show answer
A shell reads PATH when it starts, so an already-open terminal still has the old value. Either open a new terminal window, or run source ~/.zshrc in the current one. Then which flutter should print a path inside the Flutter directory.
Exercise
You installed Flutter into C:\Program Files\flutter and flutter upgrade fails with permission errors. Why does it fail, and what is the recommended fix?
Show answer
Flutter writes to its own directory when it updates and when it downloads artifacts into bin/cache. A protected location such as Program Files denies those writes to a normal user. Move the SDK, or re-clone it, into a folder you own, such as %USERPROFILE%\development\flutter, then update PATH to the new bin directory.
Exercise
You run flutter channel beta but the version output does not reflect the beta release. What command did you skip?
Show answer
flutter upgrade. Switching the channel changes the branch, and the upgrade step updates the checkout to the latest commit on that channel and downloads the matching Dart SDK and engine artifacts.