Issue
I have var number; and it gets assigned by some calculations.
If I do print(number); I get NaN as response;
I expected that I would be able to do something like
if (number is NaN)
But I get NaN is not defined.
How to check if variable is NaN in flutter?
Solution
NAN is a CONSTANT so you can do this
if (number == double.nan)
also you have this property isNaN but to use it you must provide the type because it's available only for nums so either double or int
if (number.isNaN)
Answered By - Raouf Rahiche
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.