I have two lists, the first list is filters.amenities and the second list is q.chargingStation!.amenities. I need to iterate over each row in q.chargingStation!.amenities and compare whether filters.amenities contains at least one row from the q.chargingStation!.amenities list. If it contains, then fulfill the condition. I've created methods to iterate over these lists, but now how do I compare them so that the contains method works?
if (getNameAmenitiesList(filters.amenities).contains(q.chargingStation!.amenities)) {
print('Working');
}
List<String> getNameAmenitiesList(List<String> amenities) {
final List<String> result = [];
for (int i = 0; i < amenities.length; i++) {
result.add(amenities[i]);
}
return result;
}
String getNameAmenitiesFromStationList(
List<AmenitiesModel>? amenitiesFromList) {
String result = '';
for (int i = 0; i < amenitiesFromList!.length; i++) {
result = amenitiesFromList[i].name;
}
return result;
}