Installing Flutter 2.0 on MacOS(Big Sur)

zainulcain

Zainul

Posted on April 15, 2021

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 :)

💖 💪 🙅 🚩
zainulcain
Zainul

Posted on April 15, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related