Reputation: 3092
The problem is simple: What is the correct way to search element in array ?
My code is
data = [{id: 1, descripcion: Asier}, {id: 2, descripcion: Pepe}]
estateSelected= data.firstWhere((dropdown)=>dropdown.id==1);
The error that return is
Bad state: no element
Upvotes: 6
Views: 15145
Reputation: 15012
You have some errors, this should work:
var data = [{'id': 1, 'descripcion': 'Asier'}, {'id': 2, 'descripcion': 'Pepe'}];
var estateSelected = data.firstWhere((dropdown) => dropdown['id'] == 1);
print(estateSelected);
Fastest way to try is on dartpad
Upvotes: 15