Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

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}');
}

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}"); 
}  

Dart Programming - Value of Null

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

''l;k;;

/* Simple Hello, World! program */
void main(){
   print("Hello, Worldghdfgdfg!");
}

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); 
}

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'); 
}

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"); 
} 

Dart Programming - encapsulation Error

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

Dart Programming - Importing and using a Library

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

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); 
} 

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.