of static method

Elementary of(
  1. BuildContext context, {
  2. bool listen = true,
})

Implementation

static Elementary of(BuildContext context, {bool listen = true}) {
  final ElementaryProvider? inheritedTheme = listen
      ? //searches only for InheritedWidget
      context.dependOnInheritedWidgetOfExactType<ElementaryProvider>()
      : //does not establish a relationship with the target in the way that dependOnInheritedWidgetOfExactType does.
      (context
          .getElementForInheritedWidgetOfExactType<ElementaryProvider>()
          ?.widget as ElementaryProvider?);
  //expensive, searches for any Widget subclass
  // context.findAncestorWidgetOfExactType<_InheritedElementaryTheme>();

  //! No podemos retornar una excepcion aqui, para permitir usar los componentes sueltos sin theme
  return inheritedTheme?.data ??
      const Elementary(
        physics: AlwaysScrollableScrollPhysics(),
        components: {},
        fundations: {},
      );
}