Dart Programming Articles

Found 26 articles

Anonymous function in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 959 Views

A function without a name is known as an anonymous function. They behave in the exact same manner as a normal named function would. The only difference between the named and an anonymous function is how different they are in syntax.Anonymous functions are used in Dart to form closures. An anonymous function contains a self-contained block of codes, also it can be passed as a parameter to another function as well.Anonymous function Syntax(parameterList){    // inner statement(s) }ExampleNow, let's consider a simple example of an anonymous function.Consider the example shown below −void main() {    var fruits = ["Apple", "Mango", ...

Read More

Cascade notation in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

Cascade notation is used when we want to operate a sequence of operations on the same object. The cascade notation is denoted by the (..) symbol.It is similar to method chaining that we have in other programming languages and it does save us plenty of steps and need of temporary variable.ExampleConsider the following example for a representation of how the cascade notation works in Dart.class Sample{    var a;    var b;    void showA(x){       this.a = x;    }    void showB(y){       this.b = y;    }    void printValues(){       ...

Read More

Comments in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 488 Views

Comments are a set of commands that are ignored by the compiler. They are used in a scenario where you want to attach a note to your code or a section of code so that when you visit it later, you can recall it easily.The comment statements are usually ignored during the execution of the program.There are multiple types of comments in Dart, mainly these are −Single line commentsMulti-line commentsDocumentation commentsWe will explore all the above document types in this article.Single Line commentsSingle line comments make use of // (double forward slash). They extend up to a new line character.Syntax// ...

Read More

const keyword in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 810 Views

Dart provides us with two ways in which we can declare variables with fixed values. One of them is by declaring a variable with a const keyword, and the other is by declaring the variable with a final keyword.It should be noted that both of them does provide an assurance that once a value is assigned to the variable with them, it won't change, but indeed they are slightly different from one another.constA variable that is declared using the const keyword cannot be assigned any other value. Also, the variable is known as a compile-time constant, which in turn means that ...

Read More

Constructors in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 1K+ Views

Constructors are methods that are used to initialize an object when it gets created. Constructors are mainly used to set the initial values for instance variables. The name of the constructor is the same as the name of the class.Constructors are similar to instance methods but they do not have a return type.All classes in Dart have their own default constructor, if you don't create any constructor for a class, the compiler will implicitly create a default constructor for every class by assigning the default values to the member variables.We can create a constructor in Dart something like this −class ...

Read More

final keyword in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 3K+ Views

The final keyword in Dart is used to create constants or objects that are immutable in nature. The only difference between the final and const keyword is that final is a runtime-constant, which in turn means that its value can be assigned at runtime instead of the compile-time that we had for the const keyword.ExampleConsider the example shown below −void main(){    final int xy = 10;    print(xy); }Output10In the above example, we declared an int variable with a final keyword, which means that the value once assigned to it won't change.ExampleConsider the example shown below −void main(){    final ...

Read More

Getter and Setter in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 4K+ Views

Reading and writing access to objects is very important in any programming language. Getter and Setter are the exact methods that we use when we want to access the reading and writing privileges to an object's properties.SyntaxA getter usually looks something like this -returnType get fieldName {    // return the value }The returnType is the type of data we are returning. The get keyword is what tells us and the compiler that is a getter, and then lastly we have the fieldName whose value we are trying to get.A setter usually looks something like this −set fieldName {    // set the ...

Read More

Hello World in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 4K+ Views

A Hello World program is the first program that you learn whenever you are learning a new programming language. It might be a simple program but it is a great entry point as you get to know how a program works in Dart, how to run a dart file. It provides a way to test the systems and environment that you are using.An important prerequisite before running a Hello World in Dart is to have the Dart SDK installed on your local machine. You can install the Dart SDK from this link.Writing Hello World ProgramThe first thing that you need ...

Read More

Immutable annotation in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 757 Views

We know that const keyword provides immutability in objects. But what about the cases, where we want the entire class to be immutable in nature.In such cases, we make use of the immutable annotation that is present inside the meta package of dart library.Syntaximport 'pacakge:meta/meta.dart'; @immutable class User {    String name; }It should be noted that once we declare any class with the immutable notation, all its object and the object properties and methods will be immutable as well.ExampleConsider the example shown below −import 'pacakge:meta/meta.dart'; @immutable class User {    final String name;    User(this.name);    User.withPrint(this.name){ ...

Read More

Inheritance in Dart Programming

Mukul Latiyan
Mukul Latiyan
Updated on 11-Mar-2026 6K+ Views

Inheritance in dart is defined as the process in which one class derive the properties and characteristics of another class. It is helpful as it provides an ability with which we can create a new class from an existing class.Inheritance is a major component of a programming paradigm known as OOPS (Object-Oriented Programming).With the help of Inheritance, one class can make use of all the properties and characteristics of another class.In general, two classes are required for inheritance and these mainly are −Parent class - A class that is inherited by the other class is known as the parent class. ...

Read More
Showing 1–10 of 26 articles
« Prev 1 2 3 Next »
Advertisements