Hahnemann
Hahnemann

Reputation: 4648

Run a Dart program from Mac OS Terminal after installing Flutter

I installed Flutter for Mac OS which already includes Dart. However, when I try to run a simple hello world Dart program from Terminal via dart hello.dart I get the typical command not found error. I do not know where Flutter installs the Dart SDK for my .bash_profile. What is the proper way to fix this?

Upvotes: 1

Views: 870

Answers (4)

Andrew
Andrew

Reputation: 37969

To your terminal config file (for example .zshrc) add

export PATH=$PATH:path-to-your-flutter-dir/flutter/bin/cache/dart-sdk/bin

(change path-to-your-flutter-dir to real path)

close/open terminal

run

dart --version

Upvotes: 0

magnump0
magnump0

Reputation: 2566

One option to use Dart outside Flutter setup: https://dart.dev/tutorials/server/get-started

ansd the secondoption in the web-browser: https://dartpad.dev/

Upvotes: 0

Avinder Singh
Avinder Singh

Reputation: 91

To run a Dart program from Mac OS Terminal, make sure you have Dart SDK installed on your macOS using command brew info dart . If not , then follow Dart SDK installation Dart install/setup on Mac/OSX

Upvotes: 1

Rémi Rousselet
Rémi Rousselet

Reputation: 276997

Flutter indeed comes with a dart sdk. But it's not made to be used outside. It's specifically edited for flutter (some stuff removed, other added).

If you want to use dart on it's own, you still need to install dart sdk.

Upvotes: 5

Related Questions