'Flutter Firebase how to add map within array

I got list.

final services= [
  HizmetModel(title: 'ServiceA', price: 30),
  HizmetModel(title: 'ServiceB', price: 30),
  HizmetModel(title: 'ServiceD', price: 30),
];

I would like to write and read this list to Firebase like below.

enter image description here



Solution 1:[1]

Assuming that HizmetModel has a method toMap() that converts HizmetModel(title: 'ServiceA', price: 30) => {'ServiceA': 30}.

List<Map> firebaseData = services.map((e) => e.toMap());

You can upload this List to firebase as usual.

https://firebase.flutter.dev/docs/overview/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman