The `isInfinite` property in Dart checks whether a number is positive infinity or negative infinity.
The syntax of double.isInfinite property is:
bool isInfinite
This isInfinite property of double true if the number is positive infinity or negative infinity; otherwise, false.
double.isInfinite returns value of type bool
.
In this example,
num
with the value 10.0.isInfinite
property to check if num
is infinite.void main() {
double num = 10.0;
bool infinite = num.isInfinite;
print('Is $num infinite? $infinite');
}
Is 10.0 infinite? false
In this example,
infinity
initialized to positive infinity.isInfinite
property to check if infinity
is infinite.void main() {
double infinity = double.infinity;
bool infinite = infinity.isInfinite;
print('Is $infinity infinite? $infinite');
}
Is infinity infinite? true
In this example,
negInfinity
initialized to negative infinity.isInfinite
property to check if negInfinity
is infinite.void main() {
double negInfinity = -double.infinity;
bool infinite = negInfinity.isInfinite;
print('Is $negInfinity infinite? $infinite');
}
Is -infinity infinite? true
In this Dart tutorial, we learned about isInfinite property of double: the syntax and few working examples with output and detailed explanation for each example.