How to show list in flutter whose id matches

Issue

I have two list of data stored in

  1. final profiles = context.watch<ProfilesBloc>().state.profiles;
  2. final users= context.watch<UsersBloc>().state.users;

I want to build the list with the only whose profile.id matches the user.id
I tried by if (user.id == profiles.id) but it’s not working
any help?

Solution

var newUser = users.where((user) => user.id.toLowerCase().contains(profiles.id.toLowerCase()).toList();

you can basically use this method to check a condition to create a new list. Feel free to alter the codes as per your requirements.

Answered By – Kaushik Chandru

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *