'How can we use the contains() method in a list of complex objects in Dart?
I have a list made up of complex objects : here is the definition of the class :
class Eleve {
final String classeCode;
final String email;
final String userId;
final String avatar;
final List defisProf;
const Eleve(
{required this.classeCode,
required this.email,
required this.userId,
required this.avatar,
required this.defisProf});
Map<String, dynamic> toMap() => {
'email': email,
'classeCode': classeCode,
'userId': userId,
'avatar': avatar,
'defisProf': defisProf,
};
factory Eleve.fromMap(Map data) => Eleve(
classeCode: data['classeCode'] ?? '',
email: data['email'] ?? '',
userId: data['userId'] ?? '',
avatar: data['avatar'] ?? '',
defisProf: data['defisProf'] ?? '',
);
}
I would like to check if the list named _mesClasses contains an Eleve whose userId is equal to a certain value.
I have a feeling that I should redefine / override the method Contains for the Eleve type... but I don't know how...
Can someone help ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
