2021年3月30日星期二

Dart/Flutter how to group/map array of objects by date/day

I have a list of data that looks like that:

{    "wallet": {...},    "transactions": [      {        "createdAd": 1617121058,        "id": 1,        "value": 100        ...      },      {        "createdAd": 1617121090,        "id": 1,        "value": 100        ...      },     ...    ]  }  

Now I need to group the transactions by date ( all transactions on the same day not same second ) to be something like below:

{    "wallet": {...},    "transactions": [      {        "createdAd": 1617121058,        "transactions": [          // list of all transactions that have been done at that day ( not time )        ]        },      {        "createdAd": 1617121058, // another day        "transactions": [          // list of all transactions that have been done at that day ( not time )        ]        },       // ...etc    ]  }  

I don't know if I should put some code here but I don't guess it will that useful as my code most of it SQLite queries and mapping so will kinda unrelated to what I need here.

https://stackoverflow.com/questions/66874871/dart-flutter-how-to-group-map-array-of-objects-by-date-day March 31, 2021 at 12:30AM

没有评论:

发表评论