Getting Started with Dart



2022-11-07

Dart Introduction

it is optimized programming language developed by google used to develop mobile and desktop application.
  1. Flutter uses dart language to develop application
  2. Dart language is C-type Programming language.
  3. Used to develop single page application
  4. extension is .dart

Dart syntax


	
	main(){
    print("hello");
		// this is single line comment
		/*
		 this is
		 multiline comments
		*/
}
	
	


Dart data-type

  1. Number - int, double
  2. String - 
  3. Boolen


Dart data-type conversion

  1. String to int :- int.parse("string");
  2. String to double : double.parse("string");
  3. Int to String : int_val.toString();
To know the data-type of variable : var_name.runTimeType

String Interpolation

  1.  Concatination : + is used to concatinate 
  2. Interpolation : ${expression}  is used to write expression in between of double quote inside print statement.
  3. $ : $varname is used to display variable content in between of double quote inside print. 

var Keyword


Dynamic keyword


if else, loop and function



main(){
// if else
if( 4 > 2 ){
// true block
}else{
 // false block
}

// for loop
for(var i = 0; i < 5; i++){
 print(i);
}

// while loop
var j = 4;
while( j < 10 ){
print(j);
j++;
}

// calling function
disp();
}

// defining function
void disp(){
 print("hi");
}





OOP Concept



class abc{

void disp(){
 print("hi");
}

}


main(){
  abc x = abc();//crearing object 
	x.disp(); // calling function
}