I have a list whose type is model. I have listed the model below. There is also a dropdown list in which I display the data. But I faced the problem that I have duplicate elements. Can you tell me how I can remove duplicate elements?
dropdown
final List<MyModel> mainList;
...
items: [
...mainList.map((item) {
return DropdownMenuItem(
value: item,
child: SizedBox(
child: Row(
model
class MyModel {
MyModel ({
required this.id,
required this.startedAt,
required this.name,
});
late final int id;
late final String startedAt;
late final String name;
MyModel.fromJson(Map<String, dynamic> json){
id = json['id'];
startedAt = json['started_at'];
name= json['name'];
}
Map<String, dynamic> toJson() {
final _data = <String, dynamic>{};
_data['id'] = id;
_data['started_at'] = startedAt;
_data['name'] = name;
return _data;
}
}