setEvents method
void
setEvents(
- DatabaseReference? ref
Implementation
void setEvents(DatabaseReference? ref) {
if (ref == null) {
return;
}
ref.once().then((DatabaseEvent event) {
for (final OnceCallback listener in _onceListeners) {
listener(event);
}
//ignore: unnecessary_lambdas
}).catchError((Object error) {
setError(error);
});
_addedSubscription.add(ref.onChildAdded.listen((DatabaseEvent event) {
for (final EventCallback listener in _addedListeners) {
listener(event);
}
}, onError: (Object error, StackTrace stackTrace) {
setError(error);
}, onDone: () {
// print('done');
}));
_removedSubscription.add(ref.onChildRemoved.listen((DatabaseEvent event) {
for (final EventCallback listener in _removedListeners) {
listener(event);
}
}, onError: (Object error, StackTrace stackTrace) {
setError(error);
}, onDone: () {
// print('done');
}));
_changedSubscription.add(ref.onChildChanged.listen((DatabaseEvent event) {
for (final EventCallback listener in _changedListeners) {
listener(event);
}
}, onError: (Object error, StackTrace stackTrace) {
setError(error);
}, onDone: () {
// print('done');
}));
_movedSubscription.add(ref.onChildMoved.listen((DatabaseEvent event) {
for (final EventCallback listener in _movedListeners) {
listener(event);
}
}, onError: (Object error, StackTrace stackTrace) {
setError(error);
}, onDone: () {
// print('done');
}));
_valueSubscription.add(ref.onValue.listen((DatabaseEvent event) {
for (final EventCallback listener in _valueListeners) {
listener(event);
}
}, onError: (Object error, StackTrace stackTrace) {
setError(error);
}, onDone: () {
// print('done');
}));
}