Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.

Get Started 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

I am getting error “cmdline-tools component is missing” after installing Flutter and Android Studio… I added the Android SDK. How can I solve them?

Solution: Step 1: I fixed the problem by opening Android Studio. Step 2: Click to More Actions. Step 3: Then click on ‘SDK Manager’. Step 4: In Read More

Read More

What is Flutter? & How it is Better than it’s Counterparts? – Cross Platform

What is Flutter? Flutter is an open-source UI software development kit created by Google. It’s used to develop cross-platform applications for Android, iOS, Linux, Mac, Windows, Google Read More

Read More

Creating Your First Flutter Project: A Step-by-Step Guide

Creating your first Flutter project is an exciting journey into mobile app development. Here’s a step-by-step guide to help you get started: 1. Install Flutter Before you Read More

Read More

What is flutter and How Flutter Works & Architecture

What is flutter? Flutter is an open-source UI software development kit created by Google. It is used to build natively compiled applications for mobile, web, and desktop Read More

Read More

Execution failed for task’:app:processDebugGoogleServices’.> No matching client found for package name’com.cotocus.holidaylandmark.publisher.holidaylandmark_publisher’ android studio-SOLVED

What went wrong: Execution failed for task ‘:app:processDebugGoogleServices’. No matching client found for package name ‘com.example.myapp ‘ Step -1: check your google-services.json and build.gradle matching applicationId and Read More

Read More

How to Make a Confirm Dialog in Flutter

A confirm dialog is a dialog box that asks users to approve the requested operation. It usually appears with button pairs like Yes/No, OK/Cancel, Agree/Disagree. Confirm dialogs Read More

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