我有一些带有名称和计数器参数的对象,这些对象存储在列表中。我的列表中有一些项目具有重复的“名称”参数。我想在列表内删除重复项,并将重复项的计数器添加到重复对象的参数中。
class Person{
Person({this.name, this.counter)};
String name;
int counter;
}
List<Person> theList = [];
theList.add(Person(name:"Ben", counter: 2);
theList.add(Person(name:"Ben", counter: 5);
//I need a function that changes the List to show Ben with counter 7