Ben Ajax
Ben Ajax

Reputation: 740

How to get the length of map values flutter

Map<String, bool> _toDos = {
      'case1': true,
      'case2': false,
      'case3': false,
      'case4': false,
      'case5' : false

    };

Say I have a map object like this and I want to get the length of strings that contains "true" values. How do I do so with flutter?

_toDos.length gives me the length of the map but I want to get the length of items that contain only "true" values.

Upvotes: 1

Views: 1664

Answers (1)

Ben Ajax
Ben Ajax

Reputation: 740

_todos.values.where((element) => element == true).length

Upvotes: 2

Related Questions