advanceInternal method

bool advanceInternal(
  1. double elapsedSeconds, {
  2. bool nested = false,
  3. bool isRoot = false,
})

Update any dirty components in this artboard.

Implementation

bool advanceInternal(double elapsedSeconds,
    {bool nested = false, bool isRoot = false}) {
  bool didUpdate = false;
  if (_dirtyLayout.isNotEmpty) {
    var dirtyLayout = _dirtyLayout.toList();
    _dirtyLayout.clear();
    syncStyle();
    for (final layoutComponent in dirtyLayout) {
      layoutComponent.syncStyle();
    }
    layoutNode.calculateLayout(width, height, LayoutDirection.ltr);
    if (dirt & ComponentDirt.layoutStyle != 0) {
      // Maybe we can genericize this to pass all styles to children if
      // the child should inherit
      cascadeAnimationStyle(interpolation, interpolator, interpolationTime);
    }
    // Need to sync all layout positions.
    for (final layout in _dependencyOrder.whereType<LayoutComponent>()) {
      layout.updateLayoutBounds();
      if ((layout == this && super.advance(elapsedSeconds)) ||
          (layout != this && layout.advance(elapsedSeconds))) {
        didUpdate = true;
      }
    }
  }

  for (final controller in _animationControllers) {
    if (controller.isActive) {
      controller.apply(context, elapsedSeconds);
      didUpdate = true;
    }
  }
  hasChangedDrawOrderInLastUpdate = false;

  // Joysticks can be applied before updating components if none of the
  // joysticks have "external" control. If they are controlled/moved by some
  // other component then they need to apply after the update cycle, which is
  // less efficient.
  var canApplyJoysticksEarly = canPreApplyJoysticks();
  if (canApplyJoysticksEarly) {
    applyJoysticks(isRoot: isRoot);
  }

  if (isRoot) {
    updateDataBinds();
  }
  if (updateComponents() || didUpdate) {
    didUpdate = true;
  }

  // If joysticks applied, run the update again for the animation changes.
  if (!canApplyJoysticksEarly && applyJoysticks(isRoot: isRoot)) {
    if (updateComponents()) {
      didUpdate = true;
    }
  }

  if (nested) {
    var active = _activeNestedArtboards.toList(growable: false);
    for (final activeNestedArtboard in active) {
      if (activeNestedArtboard.advance(elapsedSeconds)) {
        didUpdate = true;
      }
    }
  }

  return didUpdate;
}