How to access the String inside the List in Map<String, List<String>>?

Viewed 47
final Map<String, List<String>> todoDate = {
'today': ['code', 'read a book']};

I am trying to display the String value in the List.

Text(todoDate['today'][0], //ERROR!
2 Answers

It is possible to get null data while reading map. And Text widget doesn't accept null value. You can provide default value on null cases.

Text(todoDate['today']?[0]??"default");
Related