A.1. Installation: Dart2

In order to run Dart on your machine, you’ll need to install the Dart SDK.

Dart 2

The following instructions install Dart 2. This book will be using Dart 2; Dart 1 will not work! If you already have the Dart SDK on your machine, ensure that it’s version 2.0.0 or greater.

Installing the Dart SDK is straightforward if you use the command line.

The command line

Many instructions in this book will involve running commands in your machine’s command line. You don’t need to be a command-line wizard to use this book. (I’m a big fan of GUIs and don’t use the command line much.) Just know that anytime you see a line of code that starts with a $, it’s a command for your terminal. In the following, ? is used to show the return value. For example, the command which dart in the OSX terminal returns the file path to your Dart SDK as shown here:

$ which dart
=> /usr/local/bin/dart

Installation differs depending on what operating system you use.

A.1.1. Mac OS

If you’re using a Mac, it’s likely that you have a program called Homebrew on your computer. If not, you need to install it. Homebrew is a command-line program that lets you download and manage software packages from the terminal. We can install it easily from the command line. First, check to see if it’s installed:

Warning

If you’re copying and pasting command-line commands, be sure to remove the first $.

$ brew -v

If your terminal prints Homebrew 1.x.x, then you’re good to go. Otherwise, you need to install Homebrew. You can find instructions for installing Homebrew via the command line at https://brew.sh. Homebrew will walk you through the steps in your terminal.

Second, install Dart SDK. Thanks to Homebrew, this is incredibly easy:

$ brew tap dart-lang/dart
$ brew install dart

Now, in your terminal, run this command to make sure everything is in its right place:

$ dart -v
 
=> Dart VM version: 2.x.x...

A.1.2. Windows OS

On Windows, the easiest way to install Dart is via the package manager, Chocolately. With Chocolatey on your machine, you simply have to run

C:> choco install dart-sdk

A.1.3. Linux

The easiest way to install on Ubuntu is with this series of steps. Using all these commands will ensure that Dart automatically updates whenever the newest version is released.

For a one-time setup step

$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo sh -c 'curl 
 https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
$ sudo sh -c 'curl https://storage.googleapis.com/download.dartlang.org/
 linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

Now, install the Dart SDK:

$ sudo apt-get update
$ sudo apt-get install dart
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.88.54