watch<T extends ReactterContext?> method

T watch<T extends ReactterContext?>([
  1. ListenStates<T>? listenStates
])

Gets the ReactterContext's instance of T from the closest ancestor of ReactterProvider and watch all ReactterHook or ReactterHook defined in first paramater(listenStates) to re-render the widget tree.

final appContext = context.watch<AppContext>();
final appContextWatchHook = context.watch<AppContext>((ctx) => [ctx.stateHook]);
final appContextNullable = context.wath<AppContext?>();

If T is nullable and no matching ReactterContext is found, watch will return null.

If T is non-nullable and the ReactterContext obtained returned null, will throw ProviderNullException.

This method is equivalent to calling:

ReactterProvider.contextOf<T>(context, listenStates: listenStates);

Implementation

T watch<T extends ReactterContext?>([ListenStates<T>? listenStates]) {
  return ReactterProvider.contextOf<T>(this, listenStates: listenStates);
}