Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

how to filter a list with condition in dart

 have a list and I want to put a condition on it when i click button display only that category. for example:

when i click india then display all trip of india

when i click india then display all trip of israel

   var my = snapshot.data;

print(my);

output of print is mentioned in below

[Profile{id: 32, image_name: magnificent-shimla-manali-tour-780.jpeg, slug: India,slug1: Himachal Pradesh,slug2: Chowari,TripTitle: Family Tour Packages}, Profile{id: 32, image_name: mussoorie-tour-package-1272.jpeg, slug: India,slug1: Jharkhand,slug2: Rānchī,TripTitle: Popular Family Tour}, Profile{id: 34, image_name: adventurous-uttarakhand-tour-5972.jpg, slug: India,slug1: Himachal Pradesh,slug2: Shimla,TripTitle: Shimla Calling Tour}, Profile{id: 35, image_name: delhi-agra-jaipur-tour-36.jpeg, slug: India,slug1: Rajasthan,slug2: Jaipur,TripTitle: Rajasthan Tour Packages}, Profile{id: 29, image_name: DazuJuSBXfQEXPyJ2E6W.jpg, slug: India,slug1: Uttarakhand,slug2: Rishīkesh,TripTitle: Uttarakhand Adventure Tour}, Profile{id: 34, image_name: family-holiday1.jpg, slug: India,slug1: Himachal Pradesh,slug2: Manāli,TripTitle: Shimla Manal Honeymoon}, Profile{id: 34, image_name: honeymoon.jpg, slug: India,slug1: Jharkhand,slug2: Bokāro,TripTitle: Honeymoon trip Mumbai}, Profile{id: 35, image_name: thailand.

  var mydata = widget.data;

 print(mydata );

output of print which button you click

like india or isreal

To get a list with only the you can click button you list of maps as such:

slug is table field name

I/flutter ( 7419): [Profile{id: 32, image_name: magnificent-shimla-manali-tour-780.jpeg, slug: India,slug1: Himachal Pradesh,slug2: Chowari,TripTitle: Family Tour Packages}, Profile{id: 32, image_name: mussoorie-tour-package-1272.jpeg, slug: India,slug1: Jharkhand,slug2: Rānchī,TripTitle: Popular Family Tour}, Profile{id: 34, image_name: adventurous-uttarakhand-tour-5972.jpg, slug: India,slug1: Himachal Pradesh,slug2: Shimla,TripTitle: Shimla Calling Tour}, Profile{id: 35, image_name: delhi-agra-jaipur-tour-36.jpeg, slug: India,slug1: Rajasthan,slug2: Jaipur,TripTitle: Rajasthan Tour Packages}, Profile{id: 29, image_name: DazuJuSBXfQEXPyJ2E6W.jpg, slug: India,slug1: Uttarakhand,slug2: Rishīkesh,TripTitle: Uttarakhand Adventure Tour}, Profile{id: 34, image_name: family-holiday1.jpg, slug: India,slug1: Himachal Pradesh,slug2: Manāli,TripTitle: Shimla Manal Honeymoon}, Profile{id: 34, image_name: honeymoon.jpg, slug: India,slug1: Jharkhand,slug2: Bokāro,TripTitle: Honeymoon trip Mumbai}, Profile{id: 35, image_name: thailand.

display in card

Refrence:https://stackoverflow.com/questions/59423646/how-to-filter-a-list-with-condition-in-dart

Related Posts

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Artificial Intelligence