Reputation: 159
I need to get all the details of a specific client: I have a list of list for the details of all the clients:
List<List<ClienteDetails>> _listaClientDetails = List<List<ClienteDetails>> ();
I want to get the details for a specific client, and I'm trying to do it by using this code: I
var result = _listaProductosFactura.where((detailsList) => detailsList.where((cliente) => cliente.id == id)).toList();
But this code is wrong. "The return type 'Iterable' isn't a 'bool', as required by the closure's context."
Does someone know what would be the right code?
Upvotes: 0
Views: 1454
Reputation: 2229
The problem with your code is that this part of it doesn't return a boolean value :
detailsList.where((cliente) => cliente.id == id)
it returns an iterable from your inner list which is not a boolean. So the first "where" method cannot return an iterable as it doesn't have a boolean result
var result = _listaProductosFactura.where((detailsList) => //you must have a boolean result here not an iterable
//but detailsList.where((cliente) => cliente.id == id) gives you an iterable
You can do something like this to get the result you want:
List<List<ClienteDetails>> _listaClientDetails = List<List<ClienteDetails>> ();
var result;
for(List<ClienteDetails> clienteDetails in _listaClientDetails){
result = clienteDetails.where((cliente)=>cliente.id == id).toList();
//goes through the inner list and get the element where cliente.id == id
}
Upvotes: 1