Skip to content

Instantly share code, notes, and snippets.

@AlexVegner
Created January 22, 2020 16:07
Show Gist options
  • Save AlexVegner/585e265c2084a7b25177f00a5d58ebaf to your computer and use it in GitHub Desktop.
Save AlexVegner/585e265c2084a7b25177f00a5d58ebaf to your computer and use it in GitHub Desktop.
dart_var_final_const.dart
void main() {
// var
var variable = 1; // equivalent to int a1 = 1, type calculated from right part
variable = 2; // var can be mutated
// final
final imutableVariable = 'object 1'; // final is imutable
final imutableVariable2 = 'object 1'; // will create additional instance of string 'object 1'
// const
const constValue = 'object'; // compile time constant
const constValue2 = 'object'; // compiler will use 1 object for 2 const references
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment