setup abstract method

SetupFunction<T> setup(
  1. SetupBuildContext<T> context,
  2. PropsReadonlyNode<T> props
)

The setup function that runs once when the widget is created.

This function should return a SetupFunction that will be called on each rebuild. Use hooks like useSignal, useComputed, etc. to manage reactive state within this function.

Hooks are cached and reused across hot reloads based on their runtime type and position in the sequence. If the hook sequence changes during hot reload, mismatched hooks will be unmounted and recreated.

Parameters:

  • context: The setup build context providing access to widget props
  • props: A reactive node that tracks widget property changes

Returns: A widget builder function that runs on each reactive rebuild

Implementation

SetupFunction<T> setup(
    SetupBuildContext<T> context, PropsReadonlyNode<T> props);