I have a list of daily sales which includes "DateTime" & "Int" for each entry.
final data = [
DailySales(2022-03-10 00:00:00.000, 200),
DailySales(2022-03-09 00:00:00.000, 255),
DailySales(2022-02-08 00:00:00.000, 100),
DailySales(2022-02-10 00:00:00.000, 520),
DailySales(2022-01-08 00:00:00.000, 100),
DailySales(2022-01-10 00:00:00.000, 520),
];
class DailySales {
final DateTime day;
final int sales;
DailySales(this.day, this.sales);
}
Now Based on the above list, I need to dynamically generate a new list that shall includes one entry per Month of month name and the total sales for that month.
as shown in the model below:
class MonthlySales {
final String month;
final int sales;
MonthlySales(this.month, this.sales);
}
Can some help on this please