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 - Enabling Checked Mode

void main() { 
   int n="hello"; 
   print(n); 
} 

Dart Programming - First Code

main() { 
   print("Hello World!"); 
}

Deck of Cards - Full

void main() {
  var deck = new Deck();
  
  deck.removeCard('Diamonds', 'Ace');
  print(deck);
}

class Deck {
  List<Card> cards = [];
  
  Deck() {
		var ranks = ['Ace', 'Two', 'Three', 'Four', 'Five'];
    var suits = ['Diamonds', 'Hearts', 'Clubs', 'Spades'];
    
    for (var suit in suits) {
      for (var rank in ranks) {
        var card = new Card(rank, suit);
        cards.add(card);
      }
    }
  }
  
  toString() {
    return cards.toString();
  }
  
  shuffle() {
    cards.shuffle();
  }
  
  cardsWithSuit(String suit) {
    return cards.where((card) => card.suit == suit);
  }
  
  deal(int handSize) {
    var hand = cards.sublist(0, handSize);
    cards = cards.sublist(handSize);
    
    return hand;
  }
  
  removeCard(String suit, String rank) {
    cards.removeWhere((card) => (card.suit == suit) && (card.rank == rank));
  }
}

class Card {
  String suit;
  String rank;
  
  Card(this.rank, this.suit);
  
  toString() {
    return '$rank of $suit';
  }
}

test

import 'dart:async';

void main() {
  
  print("Program started");
  int elapsedTime = 0;
  Timer tmr = Timer(new Duration(seconds: 1), () {
    print('elapsedTime: $elapsedTime');
    elapsedTime += 1;
  });
  
 

  //if (elapsedTime <= 15) {

    //tmr.run();
 // }
while(tmr.isActive && elapsedTime == 0);
  print("Program Ended");

  
  
}

Dart Programming - Final Keyword

void main() { 
   final val1 = 12; 
   print(val1); 
}

Dart Programming - Example Program

void main() { 
   print('hello world'); 
}

Hello World

class TestClass {   
   void disp() {     
      print("My first dart code"); 
   } 
}  
void main() {   
   TestClass c = new TestClass();   
   c.disp();  
}

Execute DART Online

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

abcd

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

2632632

void main() { 
   print('hello world'); 
}

Advertisements
Loading...

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