Closed Mabsten closed 3 years ago
The documentation of ChangeNotifier, of which 'ValueNotifier` is basically a simple variant (albeit with different practical uses), says that
ChangeNotifier
It is O(1) for adding listeners and O(N) for removing listeners and dispatching notifications (where N is the number of listeners)"
The documentation of StateNotifier however asserts that
StateNotifier
listeners cannot add extra listeners. This makes notifying listeners O(N) versus O(N²) for ValueNotifier
TL;DR: Notifying listeners with ValueNotifier is O(N²) (as stated by state_notifier Readme) or O(N) (as stated by ChangeNotifier doc) ?
In the second case, the two classes are equivalent in terms of notifying listeners overhead (obviously not with regard to removal listeners).
The doc is outdated. ChangeNotifier was updated from O(N²) to O(N) some time ago, but the readme of state_notifier didn't follow
I got it. Thanks for the reply
I have removed the mention, so I will close this.
The documentation of
ChangeNotifier
, of which 'ValueNotifier` is basically a simple variant (albeit with different practical uses), says thatThe documentation of
StateNotifier
however asserts thatTL;DR: Notifying listeners with ValueNotifier is O(N²) (as stated by state_notifier Readme) or O(N) (as stated by ChangeNotifier doc) ?
In the second case, the two classes are equivalent in terms of notifying listeners overhead (obviously not with regard to removal listeners).