I am writing some code where I have a list that gets added to alot. Each time it gets added it has 2 values: a string and an integer. I would like that it takes all of that data and that it gets the average of the integer per string, and puts that in a list.
Example:
void main() {
List people = [];
people.add({'person': 'mike', 'score': 32});
people.add({'person': 'david', 'score': 29});
people.add({'person': 'mike', 'score': 28});
people.add({'person': 'kim', 'score': 34});
people.add({'person': 'david', 'score': 31});
people.add({'person': 'david', 'score': 31});
people.add({'person': 'kim', 'score': 32});
print(people);
}
Above you can see the list people has a few different persons and scores. I would like it that when I print(people) it shows a list like:
{['person': 'mike', 'score': 30], ['person': 'david', 'score': 30], ['person': 'kim', 'score': 33]}
As you can see above the scores are the average lists of the full list, and doubles get rounded to ints.
Is there a way to do this?