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

Changing the execution flow of a program

Dart has the usual control structures with no surprises here (refer to control.dart).

An if...else statement (with an optional else) is as follows:

var n = 25;
if (n < 10) {
  print('1 digit number: $n');
} else if (n >=  10 && n < 100){
  print('2+ digit number: $n'); // 2+ digit number: 25
} else {
  print('3 or more digit number: $n');
}

Single-line statements without {} are allowed, but don't mix the two. A simple and short if…else statement can be replaced by a ternary operator, as shown in the following example code:

num rabbitCount = 16758;
(rabbitCount > 20000) ? print('enough for this year!') : print('breed on!');   // breed on!

If the expression before ? is true, the first statement is executed, else the statement after : is executed. To test if a variable v refers to a real object, use: if (v != null) { … }.

Testing if an object v is of type T is done with...

You have been reading a chapter from
Learning Dart
Published in: Jan 2014
Publisher:
ISBN-13: 9781849697422
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