average method

double? average()

Returns the average value (arithmetic mean) of all elements.

Example:

[2, 4, 6, 8].average(); // 5.0

Implementation

double? average() {
  return averageBy((n) => n);
}