Setting up Flutter for MacOS
This tutorial will help you setup Flutter for MacOS machines. The advantage of using Flutter in Mac is the capability to create apps for both android and iOS.
Steps
- Install
flutter
via terminal using the following command:
brew install --cask flutter
This will install dart and flutter in “/usr/local/bin”
2. Check your installation. Use this command to determine if there are missing SDK tools or requirements.
flutter doctor
If you manage to install flutter, dart and its required tools, it will look like the same as the image shown below. Initially, some tools are missing. It will be marked with check if you complete Step #3.
3. Install the tools specific for Android and IOS app development. See next sections below.
4.Get the IDE’s extensions for your selected IDE.
- Visual Studio Code 1.77 or later with the Flutter extension for VS Code.
- Android Studio 2023.1 (Hedgehog) or later with the Flutter plugin for IntelliJ.
- IntelliJ IDEA 2023.1 or later with both the Flutter plugin for IntelliJ and the Android plugin for IntelliJ.
For Android Development
- Install Android Studio by downloading it through the browser.
- Go to this link: https://developer.android.com/studio
2. Once installed, head to Android Studio’s SDK manager.
3. Under the SDK Tools
tab and enable SDK command-line tools. Hit apply.
4. Back in the terminal, run the command for accepting the licenses.
flutter doctor --android-licenses
5. Run flutter doctor
once more to confirm successful setup.
6. Setup your Android Emulator.
a. Android Emulator is already included in Android Studio. All you need to do is follow the steps here: Start building Flutter Android apps on macOS
b. Take note that in Step #1 in the link, VM accelerator is not supported on MacOS anymore.
Setting the android emulator will display the virtual android device based on your configurations. We can display the flutter App in this emulator.
For IOS Development
Install development tools.
- Xcode (version 15 or up) — debugs and compiles native Swift or ObjectiveC codes
a. In your MacBook, open the App store and search for Xcode.
b. Then click buttons “get” and “install”. This will require Apple ID sign in to continue. Installation may take a while.
c. Run this line in your terminal. This configures the command-line tools to use the installed version of Xcode.
sudo sh -c 'xcode-select -s /Applications/Xcode.app/Contents/Developer && xcodebuild -runFirstLaunch'
You will be prompted to input “agree” in the terminal
c. Run this line in your terminal. Sign the xcode license agreement
sudo xcodebuild -license
You will be prompted to input “agree” in the terminal
2. Cocoapods (1.13 or up) — compile enable Flutter plugins in your native apps.
a. Run this line in your terminal to install
sudo gem install cocoapods
3. IOS Simulator — to display the flutter app in a virtual IOS.
a. install the IOS simulator — this may take a while
xcodebuild -downloadPlatform iOS
b. Run the simulator
open -a Simulator
Running the simulator will open a window or popup showing a virtual iphone.
Bonus:
How to debug?
- In VSCode, you may go to the Developer Tools to debug the flutter application by pressing cmd + Shift + P then type “Flutter: Open DevTools“. It will list options what dev tool we can use for debugging: