DEV Community

Cover image for Installing Flutter 2.0 on MacOS(Big Sur)
Zainul
Zainul

Posted on

Installing Flutter 2.0 on MacOS(Big Sur)

I've been through the pain of installing flutter recently. Theres almost no resources online that is up-to-date.

This is article would get you started with Flutter 2.0 right away.

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter fullscreen mode Exit fullscreen mode

 
Pick one. I personally use VS code.

brew install --cask android-studio

OR

brew install --cask visual-studio-code
Enter fullscreen mode Exit fullscreen mode

 
Use Homebrew to install asdf, Android SDK, haxm and JDK8.

brew install asdf
brew install android-sdk
brew install intel-haxm
brew install --cask homebrew/cask-versions/adoptopenjdk8
Enter fullscreen mode Exit fullscreen mode

 
Add the plugin for dart, flutter and ruby to asdf.

asdf plugin-add dart https://github.com/patoconnor43/asdf-dart.git
asdf plugin-add flutter
asdf plugin-add ruby https://github.com/asdf-vm/asdf-ruby.git
Enter fullscreen mode Exit fullscreen mode

 
Now you can install dart, flutter and ruby with asdf.

asdf install dart latest
asdf install flutter latest
asdf install ruby latest
Enter fullscreen mode Exit fullscreen mode

 
Take note of the installed versions by running this:

asdf list dart
asdf list flutter
asdf list ruby
Enter fullscreen mode Exit fullscreen mode

 
Run the following in order to set the global runtimes.
NOTE: Please replace my version with your results from the previous part.

asdf global dart 2.12.4
asdf global flutter 2.0.4-stable
asdf global ruby 3.0.1
Enter fullscreen mode Exit fullscreen mode

 

Lets put everything together and set things up.

 
Open up your bash or zsh rc file

vim $HOME/.zshrc
Enter fullscreen mode Exit fullscreen mode

 
Add the following into your rc file in order to allow your system to run the flutter command so it is able to locate your Android SDK.
NOTE: replace 'zainulcain' with your own username

export PATH="$PATH:/Users/zainulcain/.asdf/installs/flutter/2.0.4-stable/bin"
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
Enter fullscreen mode Exit fullscreen mode

press [esc], save and exit your rc file by typing ':wq'

 
Next you'll need to set up cocoapods.

sudo gem install cocoapods
pod setup
Enter fullscreen mode Exit fullscreen mode

 

Lets accept the iOS and Android Licenses

 
iOS License

sudo xcodebuild -license
Enter fullscreen mode Exit fullscreen mode

 
Android License

touch ~/.android/repositories.cfg
flutter doctor --android-licenses
sdkmanager --update
sdkmanager "platform-tools" "platforms;android-29” "build-tools;28.0.3"
flutter config --android-sdk /usr/local/share/android-sdk
Enter fullscreen mode Exit fullscreen mode

 
Congratulations ! If you've done everything correctly, you can run this to confirm that everything is in working order.

flutter doctor -v
Enter fullscreen mode Exit fullscreen mode

If you've enjoyed this, do give me a follow for more interesting articles :)

Top comments (5)

Collapse
 
trevor_moses_985537d4ed5e profile image
Trevor Moses

I'm getting this issue:

Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
developer.android.com/studio/index...
On first launch it will assist you in installing the Android SDK
components.
(or visit flutter.dev/docs/get-started/insta...
for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk to update to that location.

Any ideas? And thanks in advance! Everything else went great and I've been trying to figure this out forever so already this has been super helpful!

Collapse
 
aomogol profile image
Ahmet Onder Mogol

flutter config --android-sdk /Users/$USER/Library/Android/sdk

Collapse
 
alexlana777 profile image
Alexandre Lana

Wow. Just great!!! Thanks very much. Helped me a lot.

Collapse
 
zainulcain profile image
Zainul

Glad it helped :)

Collapse
 
pablonax profile image
Pablo Discobar

wow, that's awesome! I really like it! if you are interested in this topic, then check this article - dev.to/pablonax/free-flutter-templ...