Mixins in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:14:08

2K+ Views

Mixins in Dart are a way of using the code of a class again in multiple class hierarchies. We make use of the with keyword followed by one or more mixins names.Mixins can be used in two ways, the first case is when we want to make use of class code in such a way that the class doesn't have any constructor and the object of the class is extended. In such a case, we use the with keyword.Another case is when we want our mixin to be usable as a regular class, then we make use of the mixin keyword ... Read More

Loops in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:13:42

367 Views

For loop is a type of definite loop in nature. There are mainly two types of loops that Dart provides us. Mainly these are −For loopFor-in loopWe will explore both of these loops in the below post.For loopFor loop in Dart follows a standard structure of the for loop that is present in C++ or Java. The structure of for loop in Dart looks something like this −Syntaxfor (initialization; condition; step) {    // Statements }ExampleConsider the example shown below - Live Demovoid main() {    for (int i = 0; i < 5; i++) {       print('TutorialsPoint : ... Read More

Methods in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:12:49

940 Views

A method is a combination of statements which is used to attach some behavior to the class objects. It is used to perform some action on class objects, and we name methods so that we can recall them later in the program.Methods help in making the core more modular and in increasing the re-usability of the program.Information can be passed to methods through the parameters and then it can perform some operation on that information or it can even return values.Methods in a class are of two types, these are −Instance methodsClass methodsInstance MethodsInstance methods are methods that are present ... Read More

Method Overriding in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:12:04

908 Views

We know that we can access the methods that are present in the superclass from a subclass by making use of the super keyword or by simply creating objects of the subclass. Though, there may be different occasions when we want the subclass object to do things differently to the same method when invoked using subclass objects. We can achieve this by defining the same method again in the subclass with the same name, same arguments and same return type as in the same method that is present inside the superclass.Now, when we invoke that method, the method present in ... Read More

Logical Operator in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:09:07

152 Views

Logical operators in dart are used when we want to evaluate expressions by putting conditional statements in between them, which ultimately results in a Boolean value.Logical operators are only applied on Boolean operands.There are three types of logical operators that are present in Dart. In the table below all of them are mentioned along with their name and the result they produced when they are used on two Boolean operands.Let's consider two Boolean variables named, x and y, with values true and false respectively.Consider the table shown below −OperatorNameDescriptionResult&&Logical ANDReturns true if all expressions are truex && y = false||Logical ... Read More

Lists in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:08:47

524 Views

Lists in dart are an indexable collection of objects. These can contain objects of the same type as well as objects of different data type. It is also possible that we can create a list of fixed length or a list that is growable in nature.Lists in dart are 0 index-based.There are mainly two types of lists in dart. These mainly are −Fixed Length ListGrowable ListWe will explore both types of lists in the following article.Fixed Length ListA Fixed length list as the name suggest cannot grow. Also, it is not allowed to manipulate the size of it to something ... Read More

Lexical Scoping in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:08:20

1K+ Views

Dart is a lexically scoped language. Lexically scoped means that as we move downwards to the latest variable declaration, the variable value will depend on the innermost scope in which the variable is present.ExampleConsider the example shown below − Live Demovoid main(){    var language = 'Dart';    void printLanguage(){       language = 'DartLang';       print("Language is ${language}");    }    printLanguage(); }In the above example, we changed the value of the language variable inside the scope of the printLanguage() function and since we are printing the value inside the printLanguage() function, the innermost scope is the one inside ... Read More

Iterator class in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:07:19

750 Views

Iterator class in Dart is an interface that is used when we want to get items, one at a time, from an object.The iterator is initially positioned before the first element. Before accessing the first element the iterator need to be advanced using the moveNext to point to the first element. If we reached the end of the object then moveNext returns false, and all further calls to moveNext will also return false.It should be noted that if change anything in the object during the iteration, then the behaviour is unspecified.We make use of the current property of the Iterator ... Read More

Iterables in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:07:02

576 Views

Iterables in Dart are a collection of values, or "elements", that we can access in a sequential manner.The elements of the iterable are accessed by making use of an iterator getter.There are multiple collections in Dart that implement the Iterables, for example, LinkedList, List, ListQueue, MapKeySet, MapValueSet and much more.There are different constructors that we can make use of when we want to create an Iterable, like −Iterable() - creates an iterableIterable.empty() - creates an empty iterable.Iterable.generate() - creates an iterable which generates its elements dynamically.ExampleLet's consider a few examples of Iterables in Dart.Consider the example shown below − Live Demovoid main(){   ... Read More

Immutable annotation in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 13:06:05

454 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 − Live Demoimport 'pacakge:meta/meta.dart'; @immutable class User {    final String name;    User(this.name);   ... Read More

Advertisements