Tutorials Point, posted on 27th Nov, 2017

Dart Programming - Updating a list

void main() {
   List l = [1, 2, 3,4,5,6,7,8,9];
   print('The value of list before replacing ${l}');
   
   l.replaceRange(0,3,[11,23,24]);
   print('The value of list after replacing the items between the range [0-3] is ${l}');
}

Tutorials Point, posted on 24th Nov, 2017

Dart Programming - Bitwise Operators

void main() { 
   var a = 2;  // Bit presentation 10 
   var b = 3;  // Bit presentation 11 
   
   var result = (a & b); 
   print("(a & b) => ${result}");    
   result = (a | b); 
   print("(a | b) => ${result}");
   result = (a ^ b); 
   print("(a ^ b) => ${result}"); 
   
   result = (~b); 
   print("(~b) => ${result}");  
   
   result = (a < b); 
   print("(a < b) => ${result}"); 
   
   result = (a > b); 
   print("(a > b) => ${result}"); 
}  

Tutorials Point, posted on 24th Nov, 2017

Dart Programming - Value of Null

void main() { 
   int num; 
   print(num); 
}

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Conditional Expressions

void main() { 
   var a = 10; 
   var res = a > 12 ? "value greater than 10":"value lesser than or equal to 10"; 
   print(res); 
}

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Concurrency

import 'dart:isolate';  
void foo(var message){ 
   print('execution from foo ... the message is :${message}'); 
}  
void main(){ 
   Isolate.spawn(foo,'Hello!!'); 
   Isolate.spawn(foo,'Greetings!!'); 
   Isolate.spawn(foo,'Welcome!!'); 
   print('execution from main1'); 
   print('execution from main2'); 
   print('execution from main3'); 
}

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Async

import 'dart:io'; 
void main() { 
   print("Enter your name :");            
   // prompt for user input 
   String name = stdin.readLineSync();  
   // this is a synchronous method that reads user input 
   print("Hello Mr. ${name}"); 
   print("End of main"); 
} 

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - encapsulation Error

library loggerlib;                            
void _log(msg) {
   print("Log method called in loggerlib msg:$msg");      
} 

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Importing and using a Library

import 'dart:math'; 
void main() { 
   print("Square root of 36 is: ${sqrt(36)}"); 
}

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Typedefs Example

typedef ManyOperation(int firstNo , int secondNo);   //function signature 
Add(int firstNo,int second){ 
   print("Add result is ${firstNo+second}"); 
}  
Subtract(int firstNo,int second){
   print("Subtract result is ${firstNo-second}"); 
}  
Divide(int firstNo,int second){ 
   print("Divide result is ${firstNo/second}"); 
}  
Calculator(int a,int b ,ManyOperation oper){ 
   print("Inside calculator"); 
   oper(a,b); 
}  
main(){ 
   Calculator(5,5,Add); 
   Calculator(5,5,Subtract); 
   Calculator(5,5,Divide); 
} 

Tutorials Point, posted on 16th Nov, 2017

Dart Programming - Typedef

typedef ManyOperation(int firstNo , int secondNo); //function signature  
Add(int firstNo,int second){ 
   print("Add result is ${firstNo+second}"); 
} 
Subtract(int firstNo,int second){ 
   print("Subtract result is ${firstNo-second}"); 
}
Divide(int firstNo,int second){ 
   print("Divide result is ${firstNo/second}"); 
}  
Calculator(int a, int b, ManyOperation oper){ 
   print("Inside calculator"); 
   oper(a,b); 
}  
void main(){ 
   ManyOperation oper = Add; 
   oper(10,20); 
   oper = Subtract; 
   oper(30,20); 
   oper = Divide; 
   oper(50,5); 
}

1 2 3 4 5 6 7 ... 16 Next
Advertisements
Loading...