Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to search in list of maps by key

I have a list of map and I want to get the map of specific key
for example :
video of letter a

List<Map<String, String>> letters = const [
  {
    'letter': 'a',
    'name' : 'ddd',
    'video' : 'ss',

  },
  {
    'letter': 'b',
    'name' : 'ddd',
    'video' : 'ss',

  },
  {
    'letter': 'c,
    'name' : 'ddd',
    'video' : 'ss',

  },
]

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I guess you can use .where method like this

List listWithVideo = letters.where((element) => element['letter'] == 'a').toList();

Now here you will get list of maps where you will find your letter a.

If you want to get only one map or the first map that has the same, you can also use firstWhere method.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading