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

You're reading from   Learning Dart Dart is the programming language developed by Google that offers a new level of simple versatility. Learn all the essentials of Dart web development in this brilliant tutorial that takes you from beginner to pro.

Arrow left icon
Product type Paperback
Published in Jan 2014
Publisher
ISBN-13 9781849697422
Length 388 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (14) Chapters Close

Preface 1. Dart – A Modern Web Programming Language 2. Getting to Work with Dart FREE CHAPTER 3. Structuring Code with Classes and Libraries 4. Modeling Web Applications with Model Concepts and Dartlero 5. Handling the DOM in a New Way 6. Combining HTML5 Forms with Dart 7. Building Games with HTML5 and Dart 8. Developing Business Applications with Polymer Web Components 9. Modeling More Complex Applications with Dartling 10. MVC Web and UI Frameworks in Dart – An Overview 11. Local Data and Client-Server Communication 12. Data-driven Web Applications with MySQL and MongoDB Index

Getting a view on the Dart tool chain

Dart comes with batteries included, which means that a complete stack of tools is provided by Google to write Dart apps, compile, test, document, and publish them. Moreover, these tools are platform independent (being made for 32- and 64-bit Linux, OS X, and Windows) and they are integrated in the Dart Editor IDE. The Dart Editor contains everything a seasoned developer needs to work with confidence on his app:

  • Syntax coloring for keywords
  • Autocompletion for class members (by typing . after a name you get a list of available properties and methods)
  • Folding/unfolding code blocks
  • Tools for navigating the code (a handy overview of the code with the Outline, find callers of a method, and so on)
  • Full debugging capabilities of both browser and server applications
  • Choose your preferred editor style by navigating to Tools | Preferences | Visual Theme
  • Quick fixes for common errors
  • Refactoring capabilities
  • Direct access to the online API documentation by navigating to Help | API Reference

The code you make is analyzed while you type, indicating warning (yellow triangles) or errors (red underscores or stop signs). To get more acquainted and experiment with these possibilities, go and read the documentation at https://www.dartlang.org/tools/editor/ and play with one of the samples such as Sunflower or Pop, Pop, Win! (you can find the samples by navigating to Tools | Welcome Page). From now on use the editor in conjunction with the code examples of the book, so that you can try them out and test changes.

The Dart execution model

How a Dart app executes is sketched in the following diagram:

The Dart execution model

Dart execution model

The Dart code produced in the Dart Editor (or in a plugin for Eclipse or IntelliJ) can:

  • Execute in the Dart VM, hosted in Dartium or Chrome (Dartium is an experimental version of Chrome to test out Dart) or directly in the operating system (the browser VM knows about HTML, the server VM does not, but can use, for example, IO and sockets, so they are not completely equivalent)
  • Be compiled to JS with the dart2js compiler, so that it can run in all recent browsers

Code libraries in Dart are called packages and the core Dart SDK contains the basic types and functionalities for working with collection, math, html, uri, json, and so on. They can be recognized by the syntax dart:prefix, for example, dart:html. If you want to use a functionality from a library in a code file, you must import it by using the following as the first statement(s) in your code (dart:core is imported by default):

import 'dart:html';

The Dart code can be tested with the unit test package, and for documentation you can use the dartdoc tool (which you can find by navigating to Tools | Generate Dartdoc in Dart Editor), which generates a local website structured like the official API documentation on the Web. The pub tool is the Dart package manager: if your app needs other packages besides the SDK, pub can install them for you (from the Tools menu item in Dart Editor, select Pub Get or Pub Upgrade) and you can also publish your apps with it in the web repository http://pub.dartlang.org/.

We will see all of these tools in action in Chapter 2, Getting to Work with Dart.

lock icon The rest of the chapter is locked
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