Skip to content

Instantly share code, notes, and snippets.

@mohit242
Created August 1, 2019 21:12
Show Gist options
  • Save mohit242/168d70b7daaa94f9dcb6dad007ed292e to your computer and use it in GitHub Desktop.
Save mohit242/168d70b7daaa94f9dcb6dad007ed292e to your computer and use it in GitHub Desktop.
FirstProgram
void main() {
String name = "Bob";
var name_ = "Bob";
// Automatically infers type. name contains refernee to String object with value "Bob"
// name = 22; Cannot assign value of different type
// Note: Dart is strongly typed
dynamic planet = "Earth";
planet = 33;
// Default value of every variable is null
int lineCount;
print(lineCount);
assert(lineCount == null);
// final variable can only be set only once; a const variable is a compile-time constant
final x = 'Bob';
const bar = 100000;
// const can also be used to create const values
var foo = const [];
foo = ["Hello"];
print(foo);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment