简体   繁体   中英

How to make flutter return a list of node names of firebase

`final dbRef = database.child("Blocos");
  dbRef.onValue.listen((event) => {
    event.snapshot.children.forEach((child) {
      if (child.key != null) {
       item.add(child.key.toString());
      }
    })
  });
  print(item);

Firebase Rtdb

when I print it only appears [], how do I make a list of the type [word1, word2] appear? I intend to use the list to make a dropdownbutton afterwards.

first, you need to check, is "blocos" has data or not. You can print on event curly brackets first. I think, the mistakes is you're not make sure, is "blocos" has data or not. Hopefully can help you. Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM