I want to sort by date a List which contains 2 different objects (ClassA and ClassB), with the same property timestamp "createdAt". I have tried this solution :
_list.sort((a, b) => a.createdAt.compareTo(b.createdAt));
It only works when _list contains a single type of objects (ClassA or ClassB) but not with both.
Anyone has an idea ? Thank you.
Solution : create an abstract class with createdAt property and implement it on childs