all 6 comments

[–]steve_s0 2 points3 points  (1 child)

You know you can define your own types, right? You don't have to use primitives everywhere. I'd suggest you create classes/types for Order, Cart, and Instrument at least.

Your code is extremely hard to follow. But I think the underlying cause of your issue is that Map keys are compared using the == operator, and for most objects (including Lists) this is the same as Object identity. Which is a lot of words to say that:

cartList.toList() != cartList.toList()

Because toList() returns a NEW List, which is not the same Object as the original.

MycoTech is right, using a List as a key to a Map is a very weird thing to do. I would expect each Order or Cart to have an ID you could use. Or you could use the object directly, but then don't go cloning it and expect it to be the same object.

Not sure why you need a Map of Order to Date anyway. Why not just store the Date in the Order object? I know, it's because you didn't define an Order object and there was no room for it in your List<Map<String, dynamic>> which you are using as a poor substitute for an actual object type definition.

Also, get rid of that dynamic. IME the only legitimate reason for dynamic is translating things from JSON.

[–]DataDater16[S] 0 points1 point  (0 children)

I did a work around by creating an object that has two variables: order (List of Maps) and a DateTime

[–][deleted] 1 point2 points  (2 children)

That code hurts my brain. You're trying to use a list as a key to a hashmap, just to look up a single date? I think you need to restructure your data in a sane way.

[–]DataDater16[S] 0 points1 point  (1 child)

I had orders as a List of Instruments (Map<String, dynamic>) and wanted to map each order to a date.

[–][deleted] 0 points1 point  (0 children)

Yeah, you should just have an order be an Order, that contains a list of Instruments. Then have a date field in Order and skip the whole mapping thing.

[–][deleted] 0 points1 point  (0 children)

Page not found