Issue
how to get the length for each list according to its key
Map mymap= <String, List>;
Example key1 : 5(length of the value(list)) key2 : 48
Solution
It seems similar to this,
you can do mymap['k1']?.length
, here ?.
means it will return null if there is no value.
Rest you can follow @zabaykal's answer.
Map<String, List> mymap = {
"k1": [1, 2, 4],
"k2": [5, 6, 7],
"k3": []
};
print(mymap['k1']?.length);
mymap.forEach((key, value) {
print('$key: ${value.length}');
});
Answered By - Yeasin Sheikh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.