Below is just about everything you need to do to install Dart on your Mac OS machine.


Prerequisites

What follows is a list of the prerequisites necessary to install Flutter on your machine. If you have everything already installed and ready to go you can safely skip this section, otherwise follow along our step by step instructions on how to get everything set up.

What you’re going to need:

  • Brew

Brew

Homebrew is the first thing every developer should install on their Mac. It’s the default package manager for Mac OSX. To install homebrew on your machine open your Terminal.app and paste /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)".

Install the Dart SDK

Add the dart repository to your brew installation to be able to install Dart by running: brew tap dart-lang/dart. Once done you can install it brew install dart. Take note of the install location.

That’s it.

Testing your Dart installation

Create a simple hello world application:

void main() {
  print('Hello World');
}

Run it by typing dart filename.dart:

Valentinos-MacBook-Pro:Desktop valentinourbano$ dart test.dart
Hello World

Install Stagehand (optional)

Stagehand lets you automatically create dart projects from the command line. It is necessary to create a new Web Project that uses Flutter for the Web interactively using Android Studio or Visual Studio Code.

To install it run: pub global activate stagehand To create a new project from the Terminal run stagehand and select which kind of project you would like to work on.

Troubleshooting

If you still have problems try following these steps:

  1. Make sure dart is correctly installed by running brew install dart again and confirming that it says that the package is already installed.
  2. Check that dart has been added to the PATH by running which dart.
  3. If it has not been automatically added try to let homebrew add it by running brew link dart.
  4. If it still doesn’t work unlink it by running brew unlink dart and link it again by running brew link dart.
  5. Finally add it yourself to your ./bash-profile. During the installation process we’ve pointed out to remember the install location of the binary.

    Take note of the install location. It is now time to use it to add it to your path by substituting it to “DARTINSTALLLOCATION”:

    export PATH="$PATH":"$HOME/DART_INSTALL_LOCATION"#dart
  6. Reload the Terminal by running source .bash-profile.
  7. Try restarting your machine.