I have this Group object
class Group {
final String dateFormatted;
final List<Event> events;
Group({required this.dateFormatted, required this.events});
}
I need to fold the group so that all Groups with common dateFormatted will be merged into the same group and create a new Group Object with that data.
I have the following issue on screen with the current structure
2
Answers
Here how you can group common date events
This might work. You want to combine a list of group object. Here you pass groups to the function as parameter and it checks whether a group exists with formattedDate or not. If exists, add events to that group else it creates a group. (If your formattedDate has hour:min:s:ms values it does not work. Be sure formattedDate has only year/month/day values.