Logical Operator in Dart Programming

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

261 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

672 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

995 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

826 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

688 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

Immutability in Dart Programming

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

735 Views

Immutability is the ability to remain constant. Whenever we talk about immutability we mention the immutable nature.In object oriented and functional programming, we make use of the immutable nature of objects a lot. Being immutable means that the state of the object cannot be modified after its creation.It is a very important topic these days when we talk about front-end development, as there are several occasions and scenarios where we want to maintain the state and the way to do that is to make use of immutability.In Dart, there are different ways with which we can achieve immutability and sometimes ... Read More

If-Else in Dart Programming

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

272 Views

If statements are a major part of any programming language as they allow us to run things based on certain conditions, that's why they come under the conditional statements category.Dart's if-else statements follow the same syntax as Java's ones.Syntaxif( condition ) {    statement }If the condition in the above if parentheses evaluate to true, then the statements inside the code block will be evaluated.ExampleConsider the example shown below − Live Demovoid main() {    var age = 10;    if(age == 10){       print("10 is perfect");    } }Since in the above code the age == 10 evaluates ... Read More

Hierarchical Inheritance in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:50:38

2K+ Views

Hierarchical inheritance is the case of inheritance when two classes inherit a single class.The syntactic representation of a hierarchical inheritance looks something like this −class A {} class B extends A {} class C extends A {}In the above syntactic representation, we can see that two classes, namely B and C are inheriting (or extending) class A.ExampleLet's consider an example of hierarchical inheritance in dart. Consider the example shown below − Live Democlass Parent{    void printName(){       print("Inside class Parent");    } } class Daughter extends Parent{    void age(age){       print("Her age is: ${age}"); ... Read More

Hello World in Dart Programming

Mukul Latiyan
Updated on 21-May-2021 12:50:00

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

Advertisements