Create dynamic list for expansion tile from Firestore data

Viewed 217

I would like to create a dynamic expansionTile, which receives as input data from Cloud Firestore.

Currently I download the data as array from Firebase and sort it into 3 different arrays ("Makeup", "Hair", Men's"). Data structure Firestore

But I have to create a list according to the following scheme:

How the List should look like

How can I merge the three lists to one such list?

enter image description here

1 Answers

You can iterate over the array and sort the data as List for each category. Say you got 3 List ie. makeup, hair, and men's. Now you can use the spread operator to make the final List

Example

final List<Entry> data = [
  Entry(
    'Makeup',
     ...makeup
  ),
  Entry(
    'Hair',
     ...hair
  ),
  Entry(
    'Men`s',
     ...mens
  ),
]
Related