Language:

Search

Find element in list Flutter / Dart

  • Share this:
post-title
post-title
List samples= [Sample(id:'1'), Sample(id:'2'),  Sample(id:'3')];
var sample = samples.where((element) => sample.id == '2').first;
print(sample);

OR

List samples= [Sample(id:'1'), Sample(id:'2'),  Sample(id:'3')];
var sample = samples.where((element) => sample.id == element.id);
print(sample);
Ammar Javed

Ammar Javed

Still Learning | Still Searching | Still Exploring | The secret of your success is determined by your daily agenda.