Introduction
Flutter is a popular framework for building cross-platform applications with a single codebase. If you’re a macOS user looking to get started with Flutter, this guide will walk you through the setup process step-by-step.
Table of Contents
- System Requirements
- Download Flutter SDK
- Install Flutter SDK
- Update Your PATH
- Install Xcode
- Install Android Studio
- Run
flutter doctor
- Create and Run a Flutter App
- Conclusion
System Requirements
Before you begin, ensure your system meets the following requirements:
- Operating System: macOS 10.14 (Mojave) or later
- Disk Space: 2.8 GB (does not include disk space for IDE/tools)
Download Flutter SDK
- Visit the Flutter Website
- Go to the Flutter official website.
- Download the SDK
- Click the “Download Flutter SDK” button to get the latest stable release.
Install Flutter SDK
- Extract the ZIP File
- Locate the downloaded ZIP file and extract it to the desired location on your system (e.g.,
~/development/flutter
).
- Locate the downloaded ZIP file and extract it to the desired location on your system (e.g.,
- Avoid Installation Locations with Spaces
- Ensure the installation path does not contain spaces (e.g., avoid
~/Program Files
).
- Ensure the installation path does not contain spaces (e.g., avoid
Update Your PATH
- Open Terminal
- Open the Terminal app.
- Update PATH Variable
- Add the Flutter
bin
directory to your PATH by modifying the.zshrc
file (or.bashrc
if you’re using bash):
nano ~/.zshrc
- Add the following line to the file:
export PATH="$PATH:`pwd`/flutter/bin"
- Add the Flutter
- Apply Changes
- Save the file and apply the changes:
source ~/.zshrc
Install Xcode
- Download and Install Xcode
- Install Xcode from the Mac App Store.
- Set Up Xcode
- Open Xcode and agree to the license agreement.
- Ensure that the Xcode command line tools are installed:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch
Install Android Studio
- Download and Install Android Studio
- Download Android Studio from the official website.
- Follow the installation instructions.
- Set Up Android SDK
- Open Android Studio and follow the setup wizard to install the necessary Android SDK components.
- Install Flutter and Dart Plugins
- In Android Studio, go to
Preferences > Plugins
. - Search for and install the “Flutter” and “Dart” plugins.
- In Android Studio, go to
Run flutter doctor
- Open Terminal
- Open a new Terminal window.
- Run
flutter doctor
- Type
flutter doctor
and press Enter. - Review the output and follow any additional setup instructions.
flutter doctor
- Type
Create and Run a Flutter App
- Create a New Project
- In the Terminal, navigate to your development directory and create a new Flutter project:
flutter create my_first_app
- Navigate to the Project Directory
- Change to the project directory:
cd my_first_app
- Run the App
- Ensure an iOS simulator is running or a physical device is connected.
- Run the app using the following command:
flutter run
Conclusion
By following these steps, you have successfully set up Flutter on your macOS machine and run your first Flutter app. For more detailed information and troubleshooting, refer to the official Flutter documentation. Happy coding!