backdoorInheritedWidget<St> static method

Store<St> backdoorInheritedWidget<St>(
  1. BuildContext context, {
  2. Object? debug,
})

Avoid using if you don't have a good reason to do so.

The backdoorInheritedWidget gives you direct access to the store for advanced use-cases. It does NOT create a dependency like _getStoreWithDependency_Untyped does, and it does NOT rebuild the state when the state changes, when you access it like this: var state = StoreProvider.backdoorInheritedWidget(context, this).state;.

Implementation

static Store<St> backdoorInheritedWidget<St>(BuildContext context, {Object? debug}) {
  final StoreProvider<St>? provider =
      context.dependOnInheritedWidgetOfExactType<StoreProvider<St>>();

  if (provider == null)
    throw _exceptionForWrongStoreType(_typeOf<StoreProvider<St>>(), debug: debug);

  return provider._store;
}