average static method

double average(
  1. Iterable<Object?> values
)

Arithmetic mean (double) of values treated as bytes.

Implementation

static double average(Iterable<Object?> values) {
  var count = 0;
  var total = BigInt.zero;
  for (final value in values) {
    total += _toBigInt(value);
    count++;
  }
  if (count == 0) {
    throw ArgumentError('Cannot compute average of empty collection');
  }
  return total.toDouble() / count;
}