gpt4 book ai didi

firebase - 使用Dart迭代DataSnapshot

转载 作者:行者123 更新时间:2023-12-03 03:43:18 24 4
gpt4 key购买 nike

void _newMessage(fb.QueryEvent event) {

fb.DataSnapshot d = event.snapshot;

// here want to process each of child of d

}

我想我应该使用d.forEach()。是否有使用Dart遍历DataSnapshot的子代的示例?

最佳答案

void addMessage( fb.DataSnapshot d){

PCDChatMessage msg = new PCDChatMessage.fromMap(d.val());

pcdChatMessages.add(msg); //todo don't duplicate messages

}

void _newMessage(fb.QueryEvent event) {

fb.DataSnapshot d = event.snapshot;

// process each child of d
d.forEach((k) => addMessage(k));

}

这对我有用-我必须正确设置Dart动态语法。

关于firebase - 使用Dart迭代DataSnapshot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42451105/

24 4 0
文章推荐: Angular 2/Dart : Binding multiple events at once
文章推荐: javascript - 为什么全局定义的变量是未定义的?
文章推荐: javascript - "Interpolate"不是一个函数
文章推荐: dart - 角 2 Dart : How to bind events correctly to dynamically generated HTML (Removing disallowed attribute
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com