Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 23, 2022 08:19 pm GMT

Dart basics - part 1

Dart is an open-source general-purpose programming language. It is originally developed by Google and later approved as a standard by ECMA. Dart is a new programming language meant for the server as well as the browser. Introduced by Google, the Dart SDK ships with its compiler.

dart has many similarities to other languages

in this topics we are going to focus in some basics of this new languages so can help you in your journey especially for those who want to try flutter

Variables :

in dart you van create variable use var keywords , or instead you specify the variable type

` var x= 'abdo';

// or

String y ='ahmed';`

using var is what they called it inferred type
so the type of the variable is detected by it's value

Note:
when using var keyword to initialize variable with a value which from specific type you cannot update the variable with value of different type


var x= 'abdo';
x=90; // show an error

Control Structure:

we mean the conditional  and iteration statements including:-  if elese   -  switch case- for loop- etc

**
IF ELSE**

`int x =9;
if(x>8){
print("x is bigger than 8");
} else {

print("x is less or equal  to 8");

}`

Loop

for(int c=0;c<9;c++){
print(c);
}

same to for loop in other languages like java

there is special loop come with list type like an array
called foreEach

it is a callback for the array , it iterates through all elements of the given array

List numbers =[2,232,23,89];
numbers.forEach((n){
print(n);
});

*SWITCH CASE *

 same as switch case in java and many languages

` var name ='ali';

switch(name){
case 'ahmed':
print('it is ahmed');

  break;case 'ali':  print('it is ali');  break;default:   print('none of above');

}
`

continued...


Original Link: https://dev.to/kururu95/dart-basics-part-1-238l

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To