【问题标题】:How to get a names List of collections indexed in a collection, in firebase in Flutter? [duplicate]如何在Flutter的firebase中获取集合中索引的集合列表? [复制]
【发布时间】:2019-08-20 21:34:40
【问题描述】:

我在实时 firebase 数据库上有以下数据: example

如您所见,“动物”、“岩石”和“蔬菜”中有更多数据。我想在数据列表中获取这些名称,如下所示:

List list = ["animals","rocks", "vegetables"];

我知道如何在 Flutter 中执行 get http 请求来获取数据:

var response =  await http.get('https://mydb.firebaseio.com/prueba.json');
pruebaFirebase = json.decode(response.body);

但它返回一个集合列表,我只需要每个集合的名称。

提前感谢亲爱的社区。​​p>

【问题讨论】:

    标签: http firebase-realtime-database flutter


    【解决方案1】:

    使用实时数据库 REST API 的 shallow 查询参数:

    https://mydb.firebaseio.com/prueba.json?shallow=true
    

    【讨论】:

    • 道格晚安,谢谢您的回复。有了这个,我得到了这个 JSON:``` {animals:true, rock: true, vegetables: true} ``` 我试图使用这些数据,但我做不到。我尝试将其转换为 pruebaFirebase = json.decode(response.body) 作为列表的列表;但它没有运行。你知道解决它的方法吗?在此先感谢道格。
    猜你喜欢
    • 2015-03-18
    • 2020-12-03
    • 2021-06-01
    • 2020-01-05
    • 2020-11-10
    • 2019-10-01
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    相关资源
    最近更新 更多