Skip to content

Instantly share code, notes, and snippets.

@fladago
Last active August 20, 2021 09:22
Show Gist options
  • Save fladago/bb9ee86d4204f63ca44397a3cb28464a to your computer and use it in GitHub Desktop.
Save fladago/bb9ee86d4204f63ca44397a3cb28464a to your computer and use it in GitHub Desktop.
//Step3
late String lateName;
// final int finalName; // error
void main() {
//Step 1
final int x;
const int y = 1;
x = 8; // ok
// y = 2; // error: Constant variables can't be assigned a value.
// x = 9; // error: The final variable 'x' can only be set once.
//Step2
var one = const [];
one = const [1, 2, 3]; // ok
// one[0] = 4; //Unsupported operation: Cannot modify an unmodifiable list
final two = const [];
// two = const [10, 3, 23]; // error
const three = [];
// three = const [10, 3, 23]; // error
//Step3
final int finalName; // ok
// print(lateName);
// LateInitializationError: Field 'lateName' has not been initialized
lateName = '#Flutter';
print(lateName); // ok
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment