averageBy method

num averageBy(
  1. num selector(
    1. T
    )
)

Calculates the average value of all elements in the iterable by mapping them to numeric values.

Example:

var list = ['a', 'abc'];
var result = list.averageBy((s) => s.length); // 2.0

Implementation

num averageBy(num Function(T) selector) => isEmpty ? 0 : sumBy(selector) / length;