I've seen this question answered multiple times already for JavaScript and other languages. There, it always comes down to get a snapshot and use a method called exists()
to check. But in Dart/Flutter, there is no such method. Here's what I have for now:
devicesRef.child(deviceId).once().then((DataSnapshot data) {
print(data.key);
print(data.value);
});
I want to check whether a node called deviceId
already exists.
So how can I check if a node exists in Firebase Realtime Database with Dart/Flutter?
I would guess, since there is no such thing as a null child value in Realtime Database, that you could simply check if data.value
is null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With