How to convert a list into map form and get results like this:
{"data":[{"id_pet":"63","id_habit":0},{"id_pet":"64","id_habbit":0}]}
My code:
event.listPet.asMap();
My list:
↓ pet: List (2 items)
↓ [0]: Pet
id_pet: 1
id_habbit: 1
↓ [1]: Pet
id_pet: 2
id_habbit: 2
2
Answers
You should make sure
toMap
method is defined in your Pet class.use
fromIterable