官术网_书友最值得收藏!

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 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>

主站蜘蛛池模板: 通海县| 庆元县| 乌鲁木齐市| 上蔡县| 闽清县| 镇远县| 常宁市| 延吉市| 安顺市| 渭源县| 兴安盟| 康马县| 福安市| 喀喇| 富平县| 建昌县| 黎平县| 中江县| 中西区| 南城县| 陈巴尔虎旗| 米脂县| 桂林市| 上蔡县| 双辽市| 岑巩县| 普宁市| 三原县| 清原| 博客| 克拉玛依市| 合水县| 绩溪县| 东台市| 天峨县| 建水县| 黄陵县| 崇仁县| 沅陵县| 呼图壁县| 辽阳县|