Flutter is a powerful framework developed by Google that allows developers to build high-quality, natively compiled applications for mobile, web, and desktop from a single codebase. If you’re new to Flutter and want to set it up on your macOS system, this beginner-friendly guide will walk you through the process step by step.
Table of Contents
- What You Need Before You Start
- Installing Homebrew
- Installing Flutter
- Running Flutter Doctor
- Installing Additional Tools
- Setting Up the Android Environment
- Running Flutter Doctor Again
- Conclusion
What You Need Before You Start
Before starting the installation process, make sure you have the following:
- A macOS computer running macOS 10.14 (Mojave) or later.
- An internet connection.
- Basic knowledge of the command line (no need to worry; we’ll keep it simple!).
Step 1: Installing Homebrew
Homebrew is a package manager for macOS that simplifies the installation of software.
- Open the Terminal application on your Mac (found in Applications > Utilities or via Spotlight search).
- Paste the following command into Terminal and press Enter:
- Follow the on-screen instructions to complete the installation. You might be asked to enter your password.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To verify the installation, type:
brew --version
If it returns a version number, Homebrew is installed correctly.
Step 2: Installing Flutter
Now, let’s install Flutter using Homebrew.
- In the Terminal, type the following command and press Enter:
- This command will download and install Flutter on your Mac. The process might take a few minutes.
brew install --cask flutter
Once the installation is complete, you can verify it by running:
flutter --version
This should display the Flutter version number along with other relevant information.
Step 3: Running Flutter Doctor
After installing Flutter, it’s important to run the flutter doctor
command, which will check your environment and report any missing dependencies.
- Run the following command in Terminal:
- The
flutter doctor
command will analyze your system and provide instructions on how to resolve any issues.
flutter doctor
This tool is incredibly helpful in guiding you through the setup process by pointing out what needs to be fixed.
Step 4: Installing Additional Tools
Based on the instructions provided by flutter doctor
, you may need to install additional tools. Here are the commands I ran to ensure everything was set up correctly:
- Install Rosetta (required for Apple Silicon Macs):
- Install Android Studio (necessary for Android development):
- Set Xcode’s command-line tools location:
- Complete initial Xcode setup:
- Install CocoaPods (used for managing iOS dependencies):
- Download iOS platform tools:
sudo softwareupdate --install-rosetta --agree-to-license
brew install --cask android-studio
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
brew install cocoapods
xcodebuild -downloadPlatform iOS
Step 5: Setting Up the Android Environment
To set up the Android environment, you need to configure the Android SDK and accept the licenses:
- Install the latest command-line tools for Android:
- Accept Android licenses:
- Set the Android SDK location (if not automatically detected):
sdkmanager --install "cmdline-tools;latest"
flutter doctor --android-licenses
flutter config --android-sdk /path/to/your/android-sdk
Step 6: Running Flutter Doctor Again
Now that all the tools and dependencies are installed, run flutter doctor
again to ensure everything is set up correctly:
In the Terminal, type:
flutter doctor
If everything is configured properly, you should see checkmarks next to each item, indicating that your environment is ready for Flutter development.
Conclusion
You’ve successfully installed Flutter on your macOS, set up the necessary tools, and configured your development environment. By following this guide, you’re now ready to start building beautiful applications with Flutter.
Remember, the flutter doctor
command is a great resource whenever you encounter setup issues, as it provides clear guidance on what needs to be fixed. Happy coding!
1 Comment
I recommend installing puro to then install flutter. Once you have puro, you can have per-project versions of flutter installed simultaneously. https://puro.dev/