of<T extends JioNotifier> static method

T of<T extends JioNotifier>(
  1. BuildContext context, {
  2. bool listen = true,
})

Access the provider from context

Implementation

static T of<T extends JioNotifier>(
  BuildContext context, {
  bool listen = true,
}) {
  final provider = listen
      ? context.dependOnInheritedWidgetOfExactType<BasicJioProvider<T>>()
      : context
                .getElementForInheritedWidgetOfExactType<
                  BasicJioProvider<T>
                >()
                ?.widget
            as BasicJioProvider<T>?;

  if (provider == null) {
    throw FlutterError(
      'No JioProvider<$T> found in context.\n'
      'Make sure you wrap your widget tree with JioProvider<$T>.',
    );
  }
  // ✅ notifier is guaranteed non-null now
  return provider.notifier!;
}