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

You're reading from   Mastering DART Master the art of programming high-performance applications with Dart

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher Packt
ISBN-13 9781783989560
Length 346 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Sergey Akopkokhyants Sergey Akopkokhyants
Author Profile Icon Sergey Akopkokhyants
Sergey Akopkokhyants
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Beyond Dart's Basics 2. Advanced Techniques and Reflection FREE CHAPTER 3. Object Creation 4. Asynchronous Programming 5. The Stream Framework 6. The Collection Framework 7. Dart and JavaScript Interoperation 8. Internalization and Localization 9. Client-to-server Communication 10. Advanced Storage 11. Supporting Other HTML5 Features 12. Security Aspects Index

Creating an object

A class is a blueprint for objects. The process of creating objects from a class is called instantiation. An object can be instantiated with a new statement from a class or through reflection. It must be instantiated before it is used.

A class contains a constructor method that is invoked to create objects from the class. It always has the same name as the class. Dart defines two types of constructors: generative and factory constructors.

A generative constructor

A generative constructor consists of a constructor name, a constructor parameter list, either a redirect clause or an initializer list, and an optional body. Dart always calls the generative constructor first when the class is being instantiated, as shown in the following code:

class SomeClass {
  // Default constructor
  SomeClass();
}

main() {
  var some = new SomeClass();
}

If the constructor is not defined, Dart creates an implicit one for us as follows:

class AnyClass {
  // implicit constructor
}

main() {...
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