扑火基地如何获取节点的所有子节点 [英] flutter firebase how do I get all the children of a node

查看:47
本文介绍了扑火基地如何获取节点的所有子节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用dart和firebase不太熟悉,我想知道如何获取某个节点的所有子节点,以及如何检查节点是否存在

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

推荐答案

类似的操作应该可以获取用户列表:

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;
}

您可以与 users 一起检查您需要检查的内容,然后返回结果;

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

这篇关于扑火基地如何获取节点的所有子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆