Reputation: 435
Flutter source files contains many times code similar to this:
@override
double computeMinIntrinsicWidth(double height) {
if (child != null)
return child!.getMinIntrinsicWidth(height);
return 0.0;
}
Please explain "!." I can't find it on list of dart operators.
Upvotes: 3
Views: 4950
Reputation: 2757
A postfix exclamation mark (!) takes the expression on the left and casts it to its underlying non-nullable type. So it changes:
String toString() {
if (code == 200) return 'OK';
return 'ERROR $code ${(error as String).toUpperCase()}';
}
to something like this:
String toString() {
if (code == 200) return 'OK';
return 'ERROR $code ${error!.toUpperCase()}';
}
You can read more about null safety in this document.
Upvotes: 3
Reputation: 4101
It's the "(not)null assertion operator" which becomes part of Dart with the Null Safety feature in the next release.
Upvotes: 0