Aron
Aron

Reputation: 21

How to add values to empty map in flutter

I am struggling on adding map inside empty list like below, How can I add map one by one to empty list ?

final List<Map<String, dynamic>> data =[];

//every time I click I want to add map inside above data

//expected output finally look like 
data = [
{'title': 'Food', 'price':15,'qty':2},
{'title': 'pen', 'price':10,'qty':3},// added one by one
{'title': 'pc', 'price':13,'qty':1},
]

Any help please

Upvotes: 0

Views: 795

Answers (1)

Robert Sandberg
Robert Sandberg

Reputation: 8597

final data = <Map<String, dynamic>>[];

data.add({'title': 'Food', 'price':15,'qty':2})

... And so on

Upvotes: 1

Related Questions