Type error when adding two derivatives of same base class in a List Type error when adding two derivatives of same base class in a List dart dart

Type error when adding two derivatives of same base class in a List


This can be solved by specifying the object type in the generics field of the map function. Since you're not specifying the type, it's being assumed to be an iterable of ShowingLocation.

Do this instead:

List<Widget> _elementsHere = _locationsRegister        .map<Widget>((e) => ShowingLocation(              num: e.num,              name: e.name,              icon: e.icon,            ))        .toList();


Another option is as keyword.

List<Widget> _elementsHere = _locationsRegister    .map((e) => (ShowingLocation(          num: e.num,          name: e.name,          icon: e.icon,        ) as Widget))    .toList();