the code is this:
Map<String, Object> _ordini = {};
//widget._ordini is a List<Map>
widget._ordini.forEach((element) {
_ordini.addAll(element);
});
print(_ordini);
in _orders I will find only the last element.
I also tried:
Map<String, Object> _ordini = {};
//widget._ordini is a List<Map>
widget._ordini.forEach((element) {
Map<String, Object> _temp = {};
_temp.addAll(element);
_ordini.addAll(_temp);
});
print(_ordini);
but the problem still remains.
2
Answers
As @OMiShah
mentioned:
but one thing you can do is sum the values like this:
lets assume this is your:
you can try this:
this is just an example to give you an idea to some how solve that issue.
Here is the answer of your question.
When you do .addAll() means at one moment it will remove everything from the list and add all new elements.
So, if you want to add one by one then you can use .addEntries({})