-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
Description
This code
void main() {
final vn = ValueNotifier<int>(0);
void foo() {
vn.removeListener(foo); // A
vn.dispose(); // B
}
vn.addListener(foo);
vn.value = 3;
}results in:
flutter: RangeError (length): Invalid value: Not in inclusive range 0..576460752303423487: -1, #0 new _List (dart:core-patch/array.dart)
#1 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:384:50)
#2 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:463:5)
while I would expect it to work. There is no exception when either line A or line B is removed.
Issue can be fixed by setting also _reentrantlyRemovedListeners to zero in dispose here:
| _count = 0; |
[!] Flutter (Channel unknown, 3.3.2, on macOS 12.5.1 21G83 darwin-arm, locale en-NL)
! Flutter version 3.3.2 on channel unknown at /.../flutter
! Upstream repository unknown
• Framework revision e3c29ec00c (6 weeks ago), 2022-09-14 08:46:55 -0500
• Engine revision a4ff2c53d8
• Dart version 2.18.1
• DevTools version 2.15.0
Xylez01 and gabrielgarciagava
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on