averageWith method Null safety

double averageWith(
  1. {required num previous,
  2. required int count}
)

Calculates the average for the provided number using the previous value and the count of items

Implementation

double averageWith({
  required num previous,
  required int count,
}) {
  final currentTotal = (previous * (count - 1)) + this;
  final average = (currentTotal / count).to2Dp;
  return double.parse(average);
}