Reputation: 1346
I have a class named TransactionModel where I have taken two property double amount, DateTime date,
Now I want to get all unique dates from List with the help of SET method..
and expecting result is 2023-01-22 and 2023-01-23 but it is showing all...looks like due to time values..
so how to use SET based on date only(Year month day)
I have used following way
final dates = datalist.map((e) => e.date).toSet();
2023-01-22 22:32:16.482
2023-01-22 22:32:25.869
2023-01-22 22:32:33.709
2023-01-22 22:32:45.509
2023-01-22 22:32:50.785
2023-01-22 22:32:57.557
2023-01-22 22:33:31.553
2023-01-23 12:06:01.882
2023-01-23 21:41:05.551
2023-01-23 21:41:18.911
Upvotes: 0
Views: 167
Reputation: 1346
It is solved with the help of StackOverflow questions
Using DateFormat
final dates = datalist.map((e) => DateFormat('dd-MM-yyyy').format(e.date)).toSet();
Upvotes: 1