concept new in category dart

appears as: new
Dart in Action

This is an excerpt from Manning's book Dart in Action.

To create a new Element, call the dart:html Element constructor using the new keyword. This step creates a new Element object for you to store in a variable and then attach to the body. The first way that dart:html allows you to create elements creates an empty HTML tag:

A class in Dart can contain simple fields, getter and setter accessors for those fields, and methods. Generically, these are known as a class’s members. In an example user-profile scenario, you may define a User class to have firstname and lastname fields and a method to return a full name, which is a concatenation of the firstname and lastname fields (see the following listing). In use, you would use the new keyword to create an instance of this class, also shown in the main() method.

Now that you have the const constructor, you can use it by creating instances of the class. Dart knows that each instance is unchanging and allows you to compare two instances for equality in a quick and efficient manner. When you’re creating an instance with a const constructor, also use the const keyword to create the instance, instead of the new keyword: