DefaultIterableDiffer diff(Iterable iterable)

Source

DefaultIterableDiffer diff(Iterable iterable) {
  assert(iterable is ObservableList);
  ObservableList collection = iterable;
 
  // A new collection instance is passed in.
  // - We need to set up a listener.
  // - We need to diff collection.
  if (!identical(_collection, collection)) {
    _collection = collection;
 
    if (_subscription != null) _subscription.cancel();
    _subscription = collection.changes.listen((_) {
      _updated = true;
      _ref.markForCheck();
    });
    _updated = false;
    return super.diff(collection);
 
    // An update has been registered since the last change detection check.
    // - We reset the flag.
    // - We diff the collection.
  } else if (_updated) {
    _updated = false;
    return super.diff(collection);
 
    // No updates has been registered.
  } else {
    return null;
  }
}