Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
DART Cookbook

You're reading from   DART Cookbook Over 110 incredibly effective, useful, and hands-on recipes to design Dart web client and server applications

Arrow left icon
Product type Paperback
Published in Oct 2014
Publisher Packt
ISBN-13 9781783989621
Length 346 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Working with Dart Tools FREE CHAPTER 2. Structuring, Testing, and Deploying an Application 3. Working with Data Types 4. Object Orientation 5. Handling Web Applications 6. Working with Files and Streams 7. Working with Web Servers 8. Working with Futures, Tasks, and Isolates 9. Working with Databases 10. Polymer Dart Recipes 11. Working with Angular Dart Index

Configuring the Dart environment

This recipe will help customize the Dart environment according to our requirements. Here, we configure the following:

  • Defining a DART_SDK environment variable
  • Making dart-sdk\bin available for the execution of the Dart command-line tools

Getting ready

We assume that you have a working Dart environment installed on your machine. If not, go to https://www.dartlang.org/tools/download.html and choose Option 1 for your platform, which is the complete bundle. Downloading and uncompressing it will produce a folder named dart, which will contain everything you need. Put this in a directory of your choice. This could be anything, but for convenience keep it short, such as d:\dart on Windows or ~/dart on Linux. On OS X, you can just drop the directory in the App folder.

How to do it...

  1. Create a DART_SDK environment variable that contains the path to the dart-sdk folder. On Windows, create and set DART_SDK to d:\dart\dart-sdk or <your-dart-sdk-path>\dart-sdk when using a dart from another folder (if you need more information on how to do this, refer to http://www.c-sharpcorner.com/UploadFile/6cde20/use-of-environment-variable-in-windows-8/). On Linux, add this to your configuration file .bashrc and/or .profile using the export DART_SDK=~/dart/dart-sdk code. On OS X, export DART_SDK=/Applications/dart/dart-sdk or in general export DART_SDK=/path/to/dart-sdk.
  2. The installation directory has a subfolder dart-sdk\bin, which contains the command-line tools. Add this subfolder to the path of your environment. On Windows, add %DART_SDK%\bin instead to the front of the path (system environment) variable and click on OK. On Linux or OS X, add export PATH=$PATH:$DART_SDK/bin to your configuration file.
  3. Reset your environment configuration file or reboot your machine afterwards for the changes to take effect.

How it works...

Setting the DART_SDK environment variable, for example, enables plugins such as dart-maven to search for the Dart SDK (dart-maven is a plugin that provides integration for Google Dart into a maven-build process). If the OS of your machine knows the path where the Dart tools reside, you can start any of them (such as the Dart VM or dartanalyzer) anywhere in a terminal or command-line session.

Test the environment variable by typing dart in a terminal and press Enter. You should see the following help text:

Usage: dart [<vm-flags>] <dart-script-file> [<dart-options>]

Executes the Dart script passed as <dart-script-file>

You have been reading a chapter from
DART Cookbook
Published in: Oct 2014
Publisher: Packt
ISBN-13: 9781783989621
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image