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
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
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 { | |
//.... | |
} |
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
abstract class Chargeable { | |
charge(); // Abstract method | |
fastCharge() { | |
print('Gotta go fast'); | |
charge(); // Call to child's implemented method | |
} | |
} |
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
// Creating a time duration of 1 minute | |
const oneMinute = Duration(minutes: 1); | |
// ... | |
Future<void> printWithDelay(String msg) async { | |
// Wait for one minute | |
await Future.delayed(oneMinute); | |
print(msg); | |
} |
OlderNewer