Skip to content

Commit

Permalink
fix(flame): The component.removeFromParent method should use `paren…
Browse files Browse the repository at this point in the history
…t.remove` internally (#2779)

The removeFromParent wasn't going through the public methods on the parent, so overwriting the remove would not allow you to detect all removing of children.
  • Loading branch information
wolfenrain committed Sep 29, 2023
1 parent bde34ef commit bdb1c79
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/flame/lib/src/components/core/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,11 @@ class Component {
void remove(Component component) => _removeChild(component);

/// Remove the component from its parent in the next tick.
void removeFromParent() => _parent?._removeChild(this);
void removeFromParent() => _parent?.remove(this);

/// Removes all the children in the list and calls [onRemove] for all of them
/// and their children.
void removeAll(Iterable<Component> components) {
components.forEach(remove);
}
void removeAll(Iterable<Component> components) => components.forEach(remove);

/// Removes all the children for which the [test] function returns true.
void removeWhere(bool Function(Component component) test) {
Expand Down

0 comments on commit bdb1c79

Please sign in to comment.