The `isEven` property in Dart returns true if and only if this integer is even.
The syntax of int.isEven property is:
bool isEven
This isEven property of int returns true if and only if this integer is even.
int.isEven returns value of type bool
.
In this example,
number1
with the value 10.isEven
property to check if it is even.void main() {
int number1 = 10;
bool isEven1 = number1.isEven;
print('$number1 is even: $isEven1');
}
10 is even: true
In this example,
number2
with the value 7.isEven
property to check if it is even.void main() {
int number2 = 7;
bool isEven2 = number2.isEven;
print('$number2 is even: $isEven2');
}
7 is even: false
In this example,
negativeNumber
with the value -6.isEven
property to check if it is even.void main() {
int negativeNumber = -6;
bool isEvenNegative = negativeNumber.isEven;
print('$negativeNumber is even: $isEvenNegative');
}
-6 is even: true
In this Dart tutorial, we learned about isEven property of int: the syntax and few working examples with output and detailed explanation for each example.