I have a List<ChickenByWeight> I'm struggling to find a way to calculate the average weight for all the chickens
class ChickenByWeight extends Equatable {
final int count;
final int weight;
ChickenByWeight({
required this.weight,
required this.count,
});
ChickenByWeight copyWith({
int? count,
int? weight,
}) {
return ChickenByWeight(
count: count ?? this.count,
weight: weight ?? this.weight,
);
}
@override
List<Object?> get props => [
count,
weight,
];
}
I'd like to return the result with this method :
double averageChickenWeight(List<ChickenByWeight> chickenByWeight) {
return ;
}