- Dart Cookbook
- Ivo Balbaert
- 404字
- 2021-08-05 17:42:44
Using Sublime Text 2 as an IDE
Dart Editor is a great environment, but Sublime Text also has many functionalities and can be used with many other languages, making it the preferred editor for many developers.
Getting ready
You can download Sublime Text free of cost for evaluation, however, for continued use, a license must be purchased from http://www.sublimetext.com/.
Tim Armstrong from Google developed a Dart plugin for Sublime Text, which can be downloaded from GitHub at Control plugin first by following the instructions at https://sublime.wbond.net/installation#st2.
How to do it...
In Sublime Text, press Ctrl + Shi ft + P (Windows or Linux) or Cmd + Shift + P (OS X; this goes for all the following commands), click on Install Package to choose that option, and then click and choose Dart to install the plugin. Any Dart file you then open shows the highlighted syntax, matching brackets, and so on.
Also, click on Menu Preferences, Settings, and then on User and add the path to your dart-sdk as the first line in this JSON file:
{ "dartsdk_path": "path\to\dart-sdk", … }
If you want to manually install this plugin, copy the contents of the dart-sublime-bundle-master
folder to a new directory named Dart
in the Sublime packages
directory. This directory has different locations on different OS. They are as follows:
- On Windows, this will likely be found at
C:\Users\{your username}\AppData\Roaming\Sublime Text 2\Packages
- On Linux, this will likely be found at
$HOME/Sublime Text 2/Pristine Packages
- On OSX, this will likely be found at
~/Library/Application Support/Sublime Text 2/Packages
How it works...
The plugin has a number of code snippets to facilitate working with Dart, for example, typing lib
expands the library statement. Other snippets include imp
for import, class
for a class template, method
for a method template, and main
for a main()
function. Typing a snippet in the pop-up window after pressing Ctrl + SHIFT + P lets you see a list of all the snippets. Use Ctrl + / to (un)comment the selected code text.
The plugin has also made a build system for you. Ctrl + B will invoke the dartanalyzer and then compile the Dart code to JavaScript with the dart2js compiler, as shown in the following screenshot. Editing and saving a pubspec.yaml
file will automatically invoke the pub get
command.

Working in Sublime Text 2
See also
- Refer to the Configuring the Dart environment recipe for the path to the Dart SDK
- 網絡云百問百答
- C++黑客編程揭秘與防范
- 物聯網(IoT)基礎:網絡技術+協議+用例
- 物聯網短距離無線通信技術應用與開發
- Windows Server 2003 Active Directory Design and Implementation: Creating, Migrating, and Merging Networks
- 中國互聯網發展報告2018
- CCNP TSHOOT(642-832)認證考試指南
- 光纖通信系統與網絡(修訂版)
- Working with Legacy Systems
- Microsoft Power Platform Enterprise Architecture
- 異構蜂窩網絡關鍵理論與技術
- TCP/IP基礎(第2版)
- Selenium WebDriver 3 Practical Guide
- 基于IPv6的家居物聯網開發與應用技術
- Building Microservices with Spring