Book Image

Learning Dart, Second Edition - Second Edition

By : Ivo Balbaert
Book Image

Learning Dart, Second Edition - Second Edition

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Learning Dart Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Built-in types and their methods


Like Ruby, Dart is a purely object-oriented (OO) language, so every variable in Dart points to an object and there are no primitive types like in Java or C#. Every variable is an instance of a class (that inherits from the Object base class) and has a type and, when uninitialized, has the null value. However, for easy use, Dart has built-in types for the numbers, Booleans, and Strings defined in dart:core that look and behave like primitive types; that is, they can be made with literal values and have the basic operations that you would expect (to make it clear, we will use full typing in builtin_types.dart, but we could have used var as well).

A String (notice the capital) is a sequence of Unicode (UTF-16) characters, for example:

String country = "Egypt";
String chineseForWorld = '世界';

They can be indicated by paired ' or " (use "" when the string contains ' and vice versa). Adjacent string literals are concatenated. If you need multiline strings, use triple...