onChildAdded method

bool onChildAdded(
  1. DatabaseReference ref,
  2. EventCallback listener
)

Add a Subscription

Implementation

bool onChildAdded(DatabaseReference ref, EventCallback listener) {
  final StreamSubscription<DatabaseEvent> sub =
      ref.onChildAdded.listen((DatabaseEvent event) {
    listener(event);
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  });
  bool added = _addedSubscription.add(sub);
  if (!added) {
    added = _addedSubscription.remove(sub);
    if (added) {
      added = _addedSubscription.add(sub);
    }
  }
  return added;
}