Dart num isFinite
Syntax & Examples
num.isFinite property
The `isFinite` property in Dart checks if a number is finite.
Syntax of num.isFinite
The syntax of num.isFinite property is:
 bool isFinite This isFinite property of num true if the number is finite; otherwise, false.
Return Type
num.isFinite returns value of type  bool.
✐ Examples
1 Checking finiteness of integers and decimals
In this example,
- We define two variables, 
number1andnumber2, with values 10 and 3.5 respectively. - We check their finiteness using the 
isFiniteproperty and store the results inresult1andresult2. - We print the results to standard output.
 
Dart Program
void main() {
  num number1 = 10;
  num number2 = 3.5;
  bool result1 = number1.isFinite;
  bool result2 = number2.isFinite;
  print('Is $number1 finite? $result1');
  print('Is $number2 finite? $result2');
}Output
Is 10 finite? true Is 3.5 finite? true
2 Checking finiteness of infinity
In this example,
- We create a variable 
numberwith the valuedouble.infinity, representing infinity. - We use the 
isFiniteproperty to check its finiteness and store the result inresult. - We print the result to standard output.
 
Dart Program
void main() {
  num number = double.infinity;
  bool result = number.isFinite;
  print('Is $number finite? $result');
}Output
Is infinity finite? false
3 Checking finiteness of NaN
In this example,
- We create a variable 
numberwith the valuedouble.nan, representing Not-a-Number (NaN). - We use the 
isFiniteproperty to check its finiteness and store the result inresult. - We print the result to standard output.
 
Dart Program
void main() {
  num number = double.nan;
  bool result = number.isFinite;
  print('Is $number finite? $result');
}Output
Is NaN finite? false
Summary
In this Dart tutorial, we learned about isFinite property of num: the syntax and few working examples with output and detailed explanation for each example.