This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables and literals in Dart (as of v2.2) | |
// This example can be run at https://dartpad.dartlang.org/8e4e9266aa82674e7e0748413b3e88b2 | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// NOTE - all data types in Dart are objects, so the default type is null | |
// TYPES OF NUMBERS - only "int" and "double" (both are 64-bit) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Control Flow in Dart (since v2.2) | |
// This example can be run at https://dartpad.dartlang.org/dd957e22c8a763138b57b0e807e2734c | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// if / else conditional | |
bool happy = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example can be run at https://dartpad.dartlang.org/c09c790d954c5d53572cb9661b36ff43 | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// The Difference between "final" and "const" in Dart (as of v2.2) | |
// Both final and const prevent a variable from being reassigned | |
// (similar to how final works in Java or how const works in JavaScript). | |
final once = "My final var"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Looping and Iteration in Dart (since v2.2) | |
// No surprises here. | |
// This example can be run at https://dartpad.dartlang.org/880e763c99d49f238578de39d5a49bdd | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// O(n) version of n(n+1)/2 series, i.e. the sum of 1 + 2 + 3 + 4...n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exception Handling in Dart (since v2.2) | |
// This example can be run at https://dartpad.dartlang.org/4d61e7617f5ea82b73223e75242ed368 | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// 🚫 Expect Error! | |
// int myInt = 40 / 10; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constructors in Dart (as of v2.5) | |
// This example can be run at https://dartpad.dartlang.org/fc100517efced76881fd0d8d37f673a8 | |
// For other examples see https://gist.github.com/kirkdrichardson | |
void main() { | |
// Use the default constructor | |
final Car c = Car(); | |
print('Car with default constructor id: ${c.id}'); | |
print('\n\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://dartpad.dartlang.org/6f21c9137b5b14a86025aa5d7dcb7d75 | |
// Frequency Counter pattern in Dart | |
void main() { | |
/** | |
* Problem Description: | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
// Object Oriented Programming Concepts in Dart ( as ov v2.5) | |
// Private Variables and Getters/Setters in Dart | |
// see https://dartpad.dartlang.org/4624e4394c7b09ae5430764abe71d8f3 | |
void main() { | |
// Default getters/setters. Though it looks like we are directly manipulating the instance variable, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Basic inheritance and polymorphism in Dart (as of v2.5) | |
// see https://dartpad.dartlang.org/030764a47bc7599b0e1853bda75c7639 | |
void main() { | |
print(''); | |
print('------------------ Tree object, Tree Reference ----------------------'); | |
print(''); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inheriting from default and named constructors in Dart (as of v2.5) | |
// See live at https://dartpad.dartlang.org/4882c662c9cb6bb13ce358b5cffe0968 | |
void main() { | |
final Van myVan = Van("Toyota", "Odyssey"); | |
print('Color: ${myVan.color}'); | |
print('Make: ${myVan.make}'); | |
print('Model: ${myVan.model}'); |
OlderNewer