Skip to content

Commit 286c975

Browse files
authored
Add explanation to ChangeNotifier (flutter#98295)
1 parent b42438f commit 286c975

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/flutter/lib/src/foundation/change_notifier.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ abstract class ValueListenable<T> extends Listenable {
104104
class ChangeNotifier implements Listenable {
105105
int _count = 0;
106106
// The _listeners is intentionally set to a fixed-length _GrowableList instead
107-
// of const [] for performance reasons.
108-
// See https://github.com/flutter/flutter/pull/71947/files#r545722476 for
109-
// more details.
107+
// of const [].
108+
//
109+
// The const [] creates an instance of _ImmutableList which would be
110+
// different from fixed-length _GrowableList used elsewhere in this class.
111+
// keeping runtime type the same during the lifetime of this class lets the
112+
// compiler to infer concrete type for this property, and thus improves
113+
// performance.
110114
static final List<VoidCallback?> _emptyListeners = List<VoidCallback?>.filled(0, null);
111115
List<VoidCallback?> _listeners = _emptyListeners;
112116
int _notificationCallStackDepth = 0;

0 commit comments

Comments
 (0)