Search code examples
flutterterminaloperating-systemhomebrewapple-m1

Installing Flutter using Homebrew


I would like to install Flutter on my Apple M1 machine using Homebrew. But I am a bit hesitant because I am not sure if this will provide any benefits or it will create more trouble (e.g. permission issues). An alternative way would to be install Flutter using its installer from its docs.

My question is, is there a recommended way to install Flutter on an Apple M1 macbook? I could not find any docs regarding installing Flutter using Homebrew.


Solution

  • Update October 2023 – Apple M1/M2

    I ended up installing Flutter in with the following steps:

    1. Install Homebrew (if you dont already have)* - install Homebrew
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    1. Install fvm using Homebrew - install fvm
    brew tap leoafarias/fvm
    brew install fvm
    
    1. Install your wanted flutter version through fvm - fvm documentation
    fvm install stable  # Installs latest stable version of flutter
    
    1. Run fvm doctor to ensure it is installed
    2. Set the default flutter version on your machine:
    fvm global stable  # sets your default flutter to the installed stable version
    
    1. After the previous command you might see in the output to change your flutter path to /Users/<YOUR_USER>/fvm/default/bin. In that case from the root of your user:
    nano .zshrc
    
    1. Then paste the following in your .zshrc file:
    export PATH="$PATH:/Users/<YOUR_USER>/fvm/default/bin"
    
    1. Then save (control + o) then hit enter and then exit (control + x)

    2. Close and reopen your terminal and check the flutter installation with fvm flutter --version

    3. Run fvm flutter doctor to resolve and install any missing components

    If fvm flutter doctor had such a warning:

    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/<YOUR_USER>/fvm/versions/stable. Consider adding /Users/<YOUR_USER>/fvm/versions/stable/bin to the front of your path.
    

    You can resolve it by uninstalling dart from brew since flutter sdks are shipped already with dart:

    brew uninstall dart