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!
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!
Just use the null assertion operator ! to remove the null error.
It would be like this:
print(todoDate['today']![0]);
Just make sure the field exists otherwise you'd need to check if it's null first. And to check it you can use the null aware operator ? in conjunction with the null-coalescing operator ?? to default it to something else instead.
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");