children property
Iterable<DataSnapshot>
get
children
The direct children in the query's index order, built lazily, each with its own ref and priority. A snapshot made by child, or taken from children, has no query: its own children come in priority order then key order.
for (final DataSnapshot child in snapshot.children) {
print('${child.key}: ${child.value}');
}
Implementation
Iterable<DataSnapshot> get children {
// A node from the cache or a get may not carry the query's index yet.
final Node current = _node.isIndexed(_index)
? _node
: _node.withIndex(_index);
if (current is! ChildrenNode || current.isEmpty) {
return const <DataSnapshot>[];
}
return current
.childrenInOrder(_index)
.map(
(NamedNode child) => DataSnapshot.internal(
DatabaseReference.internal(
ref.database,
QuerySpec.defaultAt(ref.spec.path.child(child.name)),
),
child.node,
priorityIndex,
),
);
}