Found 56 Articles for Dart Programming

Difference Between Golang and Dart

Sabid Ansari
Updated on 12-Apr-2023 09:52:17

1K+ Views

Golang and Dart are two popular programming languages used in developing web, mobile, and desktop applications. Golang is a compiled programming language that was developed by Google in 2007. On the other hand, Dart is a relatively new programming language developed by Google in 2011. Both languages have their unique features and advantages, but also their differences. In this article, we will compare Golang and Dart in terms of performance, syntax, community, and use cases. Difference Between Golang and Dart Performance Comparison One of the major factors in choosing a programming language is performance. Both Golang and Dart are known ... Read More

while and do-while in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:23:52

141 Views

While and do-while loops are also present in Dart's arsenal. They are quite similar in terms of syntax and functionality to the C's while and do-while loops.While loopA while loop is an indefinite loop that can be modified to run for a finite number of iterations based on the condition we provide.Syntaxwhile(condition){    // do this }ExampleConsider the example shown below − Live Demovoid main() {    var age = 6;    while(age < 10){       print("age is now $age");       age++;    } }Outputage is now 6 age is now 7 age is now 8 age ... Read More

Variables in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:23:21

52 Views

Dart being a statically typed language demands that we declare the type of variable that we going to use. In simpler terms, it is necessary that we define what kind of data we are going to store in the variable before making use of it.ExampleConsider the example shown below − Live Demovoid main(){    int collegeId = 1234;    // declaring and assigning a variable    print(collegeId);        // printing the variable's value    String myName = "mukul";    print(myName); }In the above example, we declared two variables named 'collegeId' and 'myName' and assigned 1234 and "mukul" as ... Read More

Typedef in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:22:56

56 Views

In Dart, we make use of Typedef when we want to create an alias for a function type that we can use as type annotations for declaring variables and return types of that function type.A typedef holds type information when a function type is assigned to a variable.Syntaxtypedef functionName(parameters)We make use of the above syntax when we want to create a Typedef in Dart.Now, let's take a look at an example when we want to assign a typedef variable to a function in a program.typdef varName = functionNameOnce we have assigned the functionName to a typedef variable, we can later invoke the original ... Read More

This keyword in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:22:32

661 Views

This keyword in dart is used to remove the ambiguity that can be caused if the class attributes and the parameters have the same name. This keyword basically represents an implicit object pointing to the current class object.We usually prefix the class attribute with this keyword whenever we want to remove the ambiguity between the class attributes and the parameters.ExampleLet's take two examples of the case where the name of the class attribute and the parameters are the same.Consider the example shown below − Live Demovoid main() {    Employee emp = new Employee('001');    emp.empCode = '111'; } class ... Read More

Test type operators in Dart Programming

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

128 Views

There are certain cases where we want to check if a variable is of a certain data type or not. Dart provides two test type operators that we can make use of.These two test type operators are −is - return true if that variable of the type we are checking againstis! - return true if that variable is not of the type that we are checking against.SyntaxThe syntax of is operator looks something like this −x is intIn the above example, x is the name of the variable and we are checking whether x is of data type int.The syntax ... Read More

Ternary Operator in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:21:25

8K+ Views

The ternary operator is a shorthand version of an if-else condition. There are two types of ternary operator syntax in Dart, one with a null safety check and the other is the same old one we encounter normally.Syntax 1condition ? expressionOne : expressionTwo;The above syntax implies that if a certain condition evaluates to true then we evaluate the expressionOne first and then the expressionTwo.ExampleLet's explore a Dart example where we make use of the above syntax of the ternary operator.Consider the example shown below − Live Demovoid main(){    var ans = 10;    ans == 10 ? print("Answer is 10") ... Read More

Switch statements in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:21:02

93 Views

Switch statements help us in cases where we want to run specific code based on certain conditions. It's true that if-else conditions also help us in the same section of code, but the switch statements reduce the complexity of the program as we will end up with less code in case of a switch if the condition checks are dense.Syntaxswitch(case){    case x:       // do something;       break;    case y:       // do something;       break;    default:       // do something; }ExampleConsider the example shown below − Live ... Read More

Super keyword in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:20:36

508 Views

Super keyword in dart is used to refer to the parent's class object's methods or variables. In simple terms, it is used to refer to the superclass properties and methods.The most important use of the super keyword is to remove the ambiguity between superclass and subclass that have methods and variables with the same name.The super keyword is able to invoke the parent's objects method and fields, as when we create an instance of the subclass in Dart, an instance of the parent class is also created implicitly.Syntaxsuper.varName or super.methodNameAs we can access both the variables and methods of the parent's ... Read More

Super constructor in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 12:19:58

563 Views

The subclass can inherit the superclass methods and variables, but it cannot inherit the superclass constructor. The superclass constructor can only be invoked with the use of the super() constructor.The super() constructor allows a subclass constructor to explicitly call the no arguments and parametrized constructor of superclass.SyntaxSubclassconstructor():super(){ }Though, it is not even necessary to use the super() keyword as the compiler automatically or implicitly does the same for us.When an object of a new class is created by making use of the new keyword, it invokes the subclass constructor which implicitly invokes the parent class's default constructor.Let's make use of an example where ... Read More

Advertisements