Home > Software design >  The method 'map' can't be unconditionally invoked because the receiver can be 'n
The method 'map' can't be unconditionally invoked because the receiver can be 'n

Time:03-15

enter image description here

there is error with the map even when i add .toList() to the map

CodePudding user response:

This error indicates that map((note) => Text(note.title)) can potentially be null.

If you are sure that you will always have items in notes, use the "!" to tell the compiler that it won't be null:

final children = notes.map((note) => Text(note.title))!.toList();
  • Related