Closed
Description
Consider this method from dart:ui
:
double? lerpDouble(num? a, num? b, double t) {
if (a == null && b == null)
return null;
a ??= 0.0;
b ??= 0.0;
return a + (b - a) * t as double;
}
When used, it is very common to know for a fact that a
and b
are not null, e.g. because they are literals. It is unfortunate that one nonetheless has to ceremoniously accompany these calls with a trailing !
, as in lerpDouble(0.0, 100.0, t)!
.
It would be nice if there was a way to say that if a
and b
are known to be statically non-null, then the return value can also be guaranteed to be statically non-null, and the !
can be dropped.
Metadata
Metadata
Assignees
Labels
No labels