public class StatefulElement extends ComponentElement
The Element corresponding to a StatefulWidget.
Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • Field Details

    • _state

      @Nullable private @Nullable State<?> _state
  • Constructor Details

    • StatefulElement

      public StatefulElement(@NotNull @NotNull StatefulWidget widget)
  • Method Details

    • mount

      public void mount(@Nullable @Nullable Element parent)
      Description copied from class: Element
      Mounts this Element into the tree.

      Called the first time the Element is inserted into the tree. Subclasses should perform initialization work here and mount their child Elements.

      CR-01 (T-05-62 / #371): every mount(Element) override in this codebase calls super.mount(parent) before doing its own work (mounting children, running the first performRebuild(), etc.) -- this base method is therefore the single choke point through which the ENTIRE mounting recursion passes, one call per Element, regardless of subtype: ContainerElement/GridViewElement.mountChildren() mounting each child through updateChildren() and updateChild(), and the mount()->performRebuild()->updateChild()->mount() cascade StatelessElement/StatefulElement drive when composing a child Widget for the first time. Checking the depth HERE, rather than separately in every subclass's own mounting method, guards the mount recursion exactly once per node without needing to duplicate the check at each override. update()/unmount()'s own recursions need no separate guard: they only ever walk a subtree whose depth was already validated here when it was first mounted, so they can never exceed RenderDepthGuard.MAX_DEPTH without first passing through an unguarded mount() call -- which this check closes.

      Overrides:
      mount in class ComponentElement
      Parameters:
      parent - the parent Element, or null if this is the root Element
    • update

      public void update(@NotNull @NotNull Widget newWidget)
      Description copied from class: Element
      Updates this Element with a new Widget.

      Called when the Widget rebuilds. Subclasses should update their reference to the Widget and perform any necessary updates.

      Overrides:
      update in class Element
      Parameters:
      newWidget - the new Widget instance
    • unmount

      public void unmount()
      Description copied from class: Element
      Removes this Element from the tree.

      Called when the Element is no longer needed. Subclasses should perform cleanup work here and unmount their child Elements.

      Overrides:
      unmount in class ComponentElement
    • getState

      @Nullable public @Nullable State<?> getState()
    • build

      public Widget build()
      Description copied from class: ComponentElement
      Builds the child Widget.
      Specified by:
      build in class ComponentElement
      Returns:
      the child Widget