This file contains 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
void main() { | |
print('Hello world'); | |
} |
This file contains 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
void main() { | |
// Create a variable name of type String | |
var name = 'John'; | |
// Create a variable last_name of type String | |
String last_name = 'Smith'; | |
// Create a dynamic variable age, which is of type int for now | |
dynamic age = 18; | |
This file contains 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:io'; | |
void main() { | |
// Read some text from console | |
var password = stdin.readLineSync(); | |
// Check if password is correct | |
if (password == 'abc') { | |
print('Access granted'); | |
} else if (password == 'xyz') { |
This file contains 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
void main() { | |
// This is an inline comment | |
var a = 5; | |
/* This | |
is | |
a | |
multilne | |
comment | |
*/ | |
} |
This file contains 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:html'; // Import dart's standart HTML processing library | |
import '../lib/mylib.dart'; // Import your own file from another folder |
This file contains 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
// Importing standart math library | |
// Note that with deferred imports we have to specify its name | |
// using _is_ keyword | |
import 'dart:math' deferred as math; | |
void main() { | |
greet(); | |
} | |
// This is a function that is async. I will talk about |
This file contains 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
class Computer { | |
String hostname; | |
int numberOfCores; | |
// Syntactic sugar for instance variable assignment | |
Computer(this.hostname, this.numberOfCores) { | |
// Some initialization code | |
} | |
void ping() { |
This file contains 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
class MacPro extends Computer { | |
double price; | |
MacPro(String hostname, int numberOfCores, this.price) : super(hostname, numberOfCores); | |
} |
This file contains 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
mixin Battery { | |
int level = 100; | |
void die() { | |
this.level = 0; | |
} | |
} | |
class Laptop extends Computer with Battery { | |
//... |
This file contains 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
class MockComputer extends Computer { | |
//.... | |
} |
OlderNewer