average property
double
average
Calculates the average value of all elements in the list. Returns 0 if the list is empty to avoid division by zero. Otherwise, returns the sum of all elements divided by the count of elements. Example:
[1, 2, 3, 4].average => 2.5
Implementation
double get average => isEmpty ? 0 : sum / length;