shouldRemove property

  1. @nonVirtual
bool shouldRemove

Whether this component should be removed or not.

It will be checked once per component per tick, and if it is true, FlameGame will remove it.

Implementation

@nonVirtual
bool get shouldRemove => _state == LifecycleState.removing;
  1. @nonVirtual
void shouldRemove=(bool value)

Setting shouldRemove to true will schedule the component to be removed from the game tree before the next game cycle.

This property is equivalent to using the method removeFromParent.

Implementation

@nonVirtual
set shouldRemove(bool value) {
  assert(value, '"Resurrecting" a component is not allowed');
  removeFromParent();
}