find<T extends ViewModel> static method
Implementation
static T find<T extends ViewModel>(
BuildContext context, {
bool listen = false,
}) {
ViewModelProviderInheritedWidget<T>? provider;
if (listen) {
provider = context.dependOnInheritedWidgetOfExactType<
ViewModelProviderInheritedWidget<T>>();
} else {
provider = context
.findAncestorWidgetOfExactType<ViewModelProviderInheritedWidget<T>>();
}
if (provider == null) {
throw 'No ViewModelProvider found for $T';
}
return provider.viewModel;
}