Dart num isInfinite
Syntax & Examples
num.isInfinite property
The `isInfinite` property in Dart returns true if the number is positive infinity or negative infinity; otherwise, it returns false.
Syntax of num.isInfinite
The syntax of num.isInfinite property is:
 bool isInfinite This isInfinite property of num true if the number is positive infinity or negative infinity; otherwise, false.
Return Type
num.isInfinite returns value of type  bool.
✐ Examples
1 Check positive infinity
In this example,
- We create a double variable 
infinityand assign it the value of positive infinity. - We check if the number is infinite using the 
isInfiniteproperty. - We then print the result to standard output.
 
Dart Program
void main() {
  double infinity = double.infinity;
  bool isInfiniteValue = infinity.isInfinite;
  print('Is $infinity infinite? $isInfiniteValue');
}Output
Is Infinity infinite? true
2 Check negative infinity
In this example,
- We create a double variable 
negativeInfinityand assign it the value of negative infinity. - We check if the number is infinite using the 
isInfiniteproperty. - We then print the result to standard output.
 
Dart Program
void main() {
  double negativeInfinity = -double.infinity;
  bool isInfiniteValue = negativeInfinity.isInfinite;
  print('Is $negativeInfinity infinite? $isInfiniteValue');
}Output
Is -Infinity infinite? true
3 Check finite number
In this example,
- We create a double variable 
finiteNumwith the value 42.0, which is a finite number. - We check if the number is infinite using the 
isInfiniteproperty. - We then print the result to standard output.
 
Dart Program
void main() {
  double finiteNum = 42.0;
  bool isInfiniteValue = finiteNum.isInfinite;
  print('Is $finiteNum infinite? $isInfiniteValue');
}Output
Is 42 infinite? false
Summary
In this Dart tutorial, we learned about isInfinite property of num: the syntax and few working examples with output and detailed explanation for each example.