watchId<T extends ReactterContext?> method

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

Gets the ReactterContext's instance of T from the closest ancestor of ReactterProvider and watch all ReactterHook or ReactterHook defined in second paramater(listenHooks) 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, listenHooks: listenHooks);

Implementation

T watchId<T extends ReactterContext?>(String id,
        [ListenHooks<T>? listenHooks]) =>
    ReactterProvider.contextOf<T>(this, id: id, listenHooks: listenHooks);