- Non-nullable by default means that any variable that is declared normally cannot be
null
. - Any operation accessing the variable before it has been assigned is illegal.
- Additionally, assigning
null
to a non-nullable variable is also not allowed.
void main() {
String word;
print(word); // illegal
word = 'Hello, ';
print(word); // legal
}
void main() {
String word;
word = null; // forbidden
world = 'World!'; // allowed
}