preAdd method

  1. @mustCallSuper
void preAdd(
  1. Component c

This method is called for every component added, both via add and addLater methods.

You can use this to setup your mixins, pre-calculate stuff on every component, or anything you desire. By default, this calls the first time resize for every component, so don't forget to call super.preAdd when overriding.


void preAdd(Component c) {
  if (debugMode() && c is PositionComponent) {
    c.debugMode = true;

  // first time resize
  if (size != null) {

  if (c is HasGameRef) {
    (c as HasGameRef).gameRef = this;

  if (c is ComposedComponent) {