公告

微信

欢迎大家私信交流

Skip to content

change_notifier

四个类

  • Listenable
  • ValueListenable
  • ChangeNotifier
  • _MergingListenable
  • ValueNotifier

构造器/工厂函数

_listener定长可配置,在addListener和_removeAt分别实现了二倍扩容/缩容。

在removeListener,如果 _notificationCallStackDepth > 0时,我们选择_listeners[i] = null,_reentrantlyRemovedListeners++。 通知调用栈深度大于0时,在列表迭代的时候不要修改列表的长度;当在迭代器之外,可以改变列表长度。

在notifyListener,可能会一层层的调用了notifyListener方法了,_notificationCallStackDepth不断变化。 当_notificationCallStackDepth 为0,且_reentrantlyRemovedListeners,此时已经在迭代器外了,可以删除_listener的子项了。

上次更新于: