Calm Experts services - Dart logo

Dart is a programming language created by Google and the tool by which Flutter applications are developed. It is very easy to learn, especially if you already know how to program in any other language.

Dart is an object-oriented language, which means that every piece of data has a specific type. For example: the number 3 is considered to be of type integer, while the text “3” is considered to be of type String. Each type has its own properties and methods (detailed later in this article), so we can access the same property (or method) of the integer 3 and the integer 8, although the outcome may be different from each other (since they are 2 different data).

We can store data in variables, so we can have access to that data at a future time. In order to do that, we need to declare the variable and we do that by specifying the data type that it will hold and giving it a random name. It is optional to assign the variable to its value at the moment of its creation or later in the code. For instance:

“`String myname;
    int price = 10; “`

Dart originally supports plenty of different types, such as: integer (non-fractional number), double (fractional number, i.e. values with decimal points), string (text value), boolean (only two allowed values: true or false), list (a set that holds other data), map (a set of values as key-value pairs), and so on…

Developers can also create custom data types, named Classes. A Class is like a mould for creating other objects, and every object is called an Instance of a certain class. Dart also allows a “new” class to inherit from another, which means that the inherited class also has the properties and methods contained in the “older” class. In this context, a property means a variable that holds some type of value and a method is a function that can receive data, perform some actions, and then return a result.

In the example shown in Image 1, we have a class called “Person” and every instance created by this mould will have the properties “name” (of type String) and “birthDate” (of type DateTime), and the method “age” (which calculates the current age of that person).

Calm Experts - Lines of code Screenshot
Image 1 n.b. this code is not intended to be used for any other means except for educational purposes
Calm Experts - Lines of code Screenshot
Image 2 n.b. this code is not intended to be used for any other means except for educational purposes

In the example shown in Image 2, we see a class named “Student” which extends (i.e inherits) the class “Person”. This means that every student is also a person, and thus a student will have all properties and methods from a person (i.e. name, birthDate and age) beyond its own (i.e. school, mathGrade and introduceMyself).

We can see that the above is true in the “introduceMyself” method. When this method is executed, the application will print two sentences as an output. The first contains the name and age information of the Student, even though we didn’t need to tell that they belong to a student since the class inherits from Person. The second one describes at which school that student studies. Also, we can see that every property or method of an object can be accessed with a dot (“.”) between the object name and the property (or method) name.

This inheritance allowed by Dart is also very important for a user interface/experience (UI/UX) designer because they can build custom widgets in their Flutter applications. To do that, one has to create a class that extends either StatelessWidget or StatefulWidget.

Last but not least, Dart supports 3rd party library imports. This means that you don’t need to write your code entirely from scratch, but you can import someone else’s code that might do exactly what you intend to do (or almost exactly, but you can fix those differences to suit your purpose). And this is a practice that will definitely save you time and money when developing with Dart, and thus should always be adopted. Flutter has been growing incredibly fast over the years and Dart libraries follow the same trend. Therefore, it is expected that developing with Dart will become increasingly fast and cheap as time goes on.


Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore


StatelessWidgets vs StatefulWidgets

When developing with Flutter, there will certainly be a need of building screen layouts, customizing existent user interfaces or managing how the screen changes with

Let us know how we can add value to your business

Book a meeting with an Expert today

Calm Experts - workspace
site background image

Let's have a chat

Learn how we Can help from here to launch.