Tutorial by Examples

Dart has If Else: if (year >= 2001) { print('21st century'); } else if (year >= 1901) { print('20th century'); } else { print('We Must Go Back!'); } Dart also has a ternary if operator: var foo = true; print(foo ? 'Foo' : 'Bar'); // Displays "Foo".
While loops and do while loops are allowed in Dart: while(peopleAreClapping()) { playSongs(); } and: do { processRequest(); } while(stillRunning()); Loops can be terminated using a break: while (true) { if (shutDownRequested()) break; processIncomingRequests(); } You can s...
Two types of for loops are allowed: for (int month = 1; month <= 12; month++) { print(month); } and: for (var object in flybyObjects) { print(object); } The for-in loop is convenient when simply iterating over an Iterable collection. There is also a forEach method that you can cal...
Dart has a switch case which can be used instead of long if-else statements: var command = 'OPEN'; switch (command) { case 'CLOSED': executeClosed(); break; case 'OPEN': executeOpen(); break; case 'APPROVED': executeApproved(); break; case 'UNSURE': ...

Page 1 of 1