I have an extension like;
extension x on num{}
and this extension contains below function;
double get wP {
assert(this >= 0.0, "value.wP: value can't be lower than 0.0!");
assert(this <= 1.0, "value.wP: value can't be bigger than 1.0!");
return (this.abs() * SizeService.instance.width).abs();}
SizeService.instance.width is a integer and it is = 50.
So, why -1.0.wp returning -50 ?
and I wan’t to block all negative variable like;
-0.0 too but if I write assert like
assert(!this.isNegative, "Error bla bla");
it is not catching the negative value 🙁
so my question is here;
how can I block all negative and nan variables or if I can’t do it, how can I convert all negative variables to positive ones ?
-0.0 is too.
because this.abs() is not working :/
thank u very much for any helpful answer!
>Solution :
-1.0.wP is in fact the same as -(1.0.wP)
Instead, try with (-1.0).wP