watchId<T extends ReactterContext?> method

T watchId<T extends ReactterContext?>(
  1. String id, [
  2. ListenStates<T>? listenStates
])

Gets the ReactterContext's instance of T from the closest ancestor of ReactterProvider and watch all ReactterHook or ReactterHook defined in second 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 watchId<T extends ReactterContext?>(
  String id, [
  ListenStates<T>? listenStates,
]) {
  return ReactterProvider.contextOf<T>(
    this,
    id: id,
    listenStates: listenStates,
  );
}