When optional named parameter is not provided, why it is not null
as expected?
void main() {
num double({v: num}) {
if (v == null)
return 0;
else
return v * 2;
}
print(double(v: 2));
print(double());
print('done');
}
which output as
4
Uncaught TypeError: v.$mul is not a function
defines a named parameter
v
of typedynamic
with the default valuenum
(a type)It should instead be
to make your code work as expected