Skip to content

Instantly share code, notes, and snippets.

@kirkdrichardson
kirkdrichardson / main.dart
Last active October 8, 2019 02:59
The Difference between "final" and "const" in Dart
// 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";
@kirkdrichardson
kirkdrichardson / main.dart
Last active October 8, 2019 02:53
Control Flow in Dart (examples)
// 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;
@kirkdrichardson
kirkdrichardson / main.dart
Last active October 8, 2019 02:59
Variable and Data Types in Dart
// 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)