-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
There are at least a few places in widgets binding where we do or do not make copies of the observers before firing them, for example - but any of those callbacks could add or remove observers. We should go through and find the places where this is getting handled incorrectly.
@pq do you think it would be helpful/possible to have an annotation for these kinds of lists? For example, if you create a list of callbacks, having some annotation on it that warns you not to iterate it unless it was a copy. E.g.
// BAD
for (final callback in _callbacks) {
callback();
}
// GOOD
for (final callback in List.of(_callbacks)) {
callback();
}
// OK, but weird.
for (final callback in _callbacks) {
// Do something else but do not callback().
}So we'd have something like final List<MyCallbackableThing> _callbacks; annotated with something like @onlyIterateCopies or something.
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team