of<T extends ViewModel> static method

T of<T extends ViewModel>(
  1. BuildContext context
)

Implementation

static T of<T extends ViewModel>(BuildContext context) {
  final viewModel = context
      .dependOnInheritedWidgetOfExactType<ViewModelProvider<T>>()
      ?.notifier;

  assert(viewModel != null, "No appropriate ViewModel found in the context.");

  return viewModel! as T;
}