flutter firebase how do I get all the children of a node

馋奶兔 提交于 2021-01-28 01:57:35

问题


I am not very familiar with using dart and firebase and I was wondering how I could get all the children of a certain node and how I could check if a node exists


回答1:


Something like this should you get the list of users:

static Future<int> getUserAmount() async {
  final response = await FirebaseDatabase.instance
      .reference()
      .child("Users")
      .once();
  var users = [];
  reponse.value.forEach((v) => users.add(v));
  print(users);
  return users.length;
}

You can check with users what you need to check and then return a result;



来源:https://stackoverflow.com/questions/49799171/flutter-firebase-how-do-i-get-all-the-children-of-a-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!