DEV Community

Cover image for How to install Flutter on macOS using homebrew and asdf

How to install Flutter on macOS using homebrew and asdf

Mr F. on January 28, 2020

The official way to install the flutter and its dependencies is a mishmash of brew install, binary downloads alongside relying on system installed ...
Collapse
 
paulhammant profile image
Paul Hammant

asdf plugin add has replaced asdf plugin install

brew install intel-haxm is replaces haxm now, and more things are casks in July2020

Collapse
 
akarsh profile image
akarsh

@0xdonut

You need to change the adding of flutter plugin
from
asdf plugin install flutter
to this
asdf plugin-add flutter
I faced installation issue and i had search the PR of asdf plugins to know how flutter is added - github.com/asdf-vm/asdf-plugins/pu... and this is plugin repo - github.com/oae/asdf-flutter where installation step is changed.

Good tutorial. Thanks for writing as I was looking to install runtimes using version manager.

Collapse
 
0xdonut profile image
Mr F.

Thanks for pointing that out, it worked for me, but I'll update for anyone else who may find issues

Collapse
 
mriecken profile image
Michael Riecken

Agreed, @akarsh - the same happened for me and the same solution solved it.

Collapse
 
akarsh profile image
akarsh

@0xdonut

Suggestion to add the location of Flutter SDK location in the guide.

At the end of the guide, you can add about how to find the location of Flutter SDK on macOS. I had to spend some time and search on the internet to know where asdf installs the plugins. If you want to start a flutter project in Android Studio you need to manually give the Flutter SDK location. I added the steps to find the location to this StackOverflow question - stackoverflow.com/a/60575597/1334228

Collapse
 
0xdonut profile image
Mr F. • Edited

Hmm that's odd.

You can find which flutter versions you have by doing

$ asdf list flutter
> 1.12.13+hotfix.7-stable

to get the path you just need to do

$ which flutter
 >  /Users/0xDonut/.asdf/shims/flutter

you can use this output to inform android studio

Collapse
 
jaysephjw profile image
Jay

This didn't work for me- ~/.asdf/shims/flutter is the executable, whereas Android Studio wants the directory. This is a problem for the Dart plugin too.

I can use ~/.asdf/installs/flutter/<version>, but now I'm not honoring asdf's global selection (or its local one if .tool-versions is in the project).

(btw thanks for the write up!)

Collapse
 
pshah2023 profile image
PranitSh • Edited

I asked the people that made the flutter plugin and they helped me out. For making flutter work with your IDE (haven't done this in Android but have in VScodium or Vscode). Answer On Stack

In command line:
asdf where flutter

In a text document:
export FLUTTER_ROOT="$/asdf/where/flutter/should/go/here"

Add that to your bash_profile above the asdf part. Or your asdf installation won't work.
With nano, ctrl o, enter, ctrl x.

Give your IDE the path to the installation of asdf where flutter (I accidentally gave it the path to the shim, it didn't worked but I restarted my computer and it did). So, if it didn't work, the change needs to take effect, restart your computer.

Collapse
 
mriecken profile image
Michael Riecken

I had an issue with sdkmanager and had to explicitly point to the Java 8 install directory by adding this line to the beginning of /usr/local/bin/sdkmanager

JAVA_HOME=/System/Volumes/Data/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

sdkmanager requires Java 8 (or some xml libraries properly linked). This should hook you up with Java 8 for the run of sdkmanager, but not set it universally through your mac.

Collapse
 
0xdonut profile image
Mr F.

didn't this work for you?

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Collapse
 
rdewolff profile image
Rom

How much do you like your flutter experience so far? I'd be glad to read more about it.

Collapse
 
0xdonut profile image
Mr F.

I've enjoyed it so far. I think there is stigma around dart as a programming language and many developers wont let go of react.

Technologies come and go. I just try to choose the best tool for the job, that allows me to get on with my job!

I'm still very much learning about the flutter ecosystem

Collapse
 
vivianfarrell profile image
Vivian Farrell

Why does everyone seem to use brew install when I have to use brew cask install?

Collapse
 
stephenhuey profile image
Stephen Charles Huey

Thanks for a detailed write-up! Do you know if the problem with Cocoapods is still an issue with Flutter on Catalina? Is it still necessary to install an old version?

Collapse
 
0xdonut profile image
Mr F.

Thanks for reading it :)

I haven't looked into it in a while, but I guess the easiest way is to run $ gem install cocoapods and then do $ pod install, if you get errors relating to pods not being installed, then you can simply uninstall and follow my instruction and it should all work.

Collapse
 
emanuel937 profile image
Emanuel937 • Edited

just run : brew install flutter
then: flutter doctor

Collapse
 
pshah2023 profile image
PranitSh • Edited

brew tap AdoptOpenJDK/openjdk

This makes brew cask install openjdk8 work.

Collapse
 
0xdonut profile image
Mr F.

Thanks, I'll add that to the instructions

Collapse
 
ppshah2023 profile image
ppshah2023

Wait, I also did brew crack install for every install command. It resulted in the same thing at the end but there was one issue, I have to use the terminal to create and use flutter commands as I can’t get vscodium to accept the flutter install location. I have to rename the flutter install package that asdf uses (which is 17.1-stable I believe) to flutter for vscodium to use it and add it to path. and then asdf can’t find it, it seems that the only way to integrate a flutter installation in vscodium is to go through the flutter website, or creating tons of command line shortcuts that change the vscodium layout, which is very annoying as I can’t get it to work. Or I would share