halfLength property

int get halfLength

Calculates and returns the half length of the current Iterable as an integer.

The getter divides the length of the Iterable by 2 using the division operator /, and then floors the result using the floor() method to obtain an integer value.

Returns the half length of the Iterable as an integer.

Example:

List<int> numbers = [1, 2, 3, 4, 5];
int res = numbers.halfLength;
print(res); // Output: 2

Implementation

int get halfLength => (this.length / 2).floor();