of<T> static method

T of<T>(
  1. BuildContext context
)

Implementation

static T of<T>(BuildContext context) {
  final ValueProvider<T>? provider =
      context.dependOnInheritedWidgetOfExactType<ValueProvider<T>>();
  if (provider == null) {
    throw FlutterError(
      'No se encontró un ValueProvider<$T> en el árbol de widgets.\n'
      'Asegúrate de envolver tu widget con un ValueProvider<$T>.\n'
      'Por ejemplo:\n'
      '  ValueProvider<$T>(value: ..., child: MiWidget())',
    );
  }
  return provider.value;
}