Open
Description
Steps to reproduce:
- Run the following program in the Dart VM:
void main() { print(null!); }
Result:
Unhandled exception:
Null check operator used on a null value
#0 main (file:///path/to/source_file.dart:2:13)
...
I dislike that this error message refers to postfix !
as the "Null check operator":
- It is referred to as the "null assertion operator" in other documentation (https://dart.dev/null-safety/understanding-null-safety#null-assertion-operator), which is inconsistent.
- "Null check operator" implies that it's performing a null check. Calling it a "null check operator" makes it confusing explaining to users that they should perform a null check first when their variable turns out to be
null
.
I think that the error message instead should be: "Null assertion operator used on a null value".
I'm using: Dart SDK version: 2.14.1 (stable) (Unknown timestamp) on "linux_x64".