The `isFinite` property in Dart returns true if the number is finite; otherwise, it returns false.
The syntax of int.isFinite property is:
bool isFinite
This isFinite property of int true if the number is finite; otherwise, false.
int.isFinite returns value of type bool
.
In this example,
3.14
to the double variable num1
.num1
is finite using the isFinite
property.void main() {
double num1 = 3.14;
bool result1 = num1.isFinite;
print('Is $num1 finite? $result1');
}
Is 3.14 finite? true
In this example,
double.infinity
to the double variable num2
.num2
is finite using the isFinite
property.void main() {
double num2 = double.infinity;
bool result2 = num2.isFinite;
print('Is $num2 finite? $result2');
}
Is infinity finite? false
In this example,
double.nan
to the double variable num3
.num3
is finite using the isFinite
property.void main() {
double num3 = double.nan;
bool result3 = num3.isFinite;
print('Is $num3 finite? $result3');
}
Is NaN finite? false
In this Dart tutorial, we learned about isFinite property of int: the syntax and few working examples with output and detailed explanation for each example.