0

I passed data from RTDB into a map.

This is the RTDB structure: RTDB

I extracted the data using schoolList['Kỹ thuật và Công nghệ']['oisp']['title'] (I called the map that was holding the data schoolList) and printed the data. It worked fine: I/flutter (28664): Quốc tế Đại học Bách khoa TP.HCM.

I tried to use data to make widget to I created a loop that would auto-generate widgets inside a list:

              HorizontalScroll(
                tile: <Widget>[
                  for (var category in categories)
                    for (var school in featuredSchool)
                      if (schoolList[category][school] != null)
                        HomeCard(
                          name: schoolList[category][school]['title'],
                          category: schoolList[category][school]
                              ['category'],
                          networkImage: NetworkImage(schoolList[category]
                              [school]['imgcard']),
                          function: () {
                            Navigator.push(
                              context,
                              MaterialPageRoute(builder: (context) {
                                return SchoolPage(
                                  school: schoolList[category]
                                      [school],
                                );
                              }),
                            );
                          },
                        )
                ],
              ),
            ),

and it did not work. But specifying to a specific data and create a single widget worked:

HomeCard(
  name: schoolList['Kỹ thuật và Công nghệ']['oisp']['title'],

How can I auto-generate my widgets? Thanks in advance!!!

3
  • Hello @ttng_ do you get any error? Commented Apr 9, 2021 at 16:02
  • No, I did not. It came out as an empty list after I printed it out Commented Apr 10, 2021 at 1:23
  • Hello @ttng_ can you please post as well a "print(schoolList)" to see if it is populated and how? Commented Apr 10, 2021 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.