of<T extends Service> static method
Get ViewModel from context
Implementation
static T of<T extends Service>(BuildContext context) {
final inherited =
context.dependOnInheritedWidgetOfExactType<_ViewModelScope<T>>();
if (inherited == null) {
throw FlutterError(
'ViewModelProvider.of<$T>() called but no ViewModelProvider<$T> found.\n'
'Make sure to wrap your widget tree with ViewModelProvider<$T>.',
);
}
return inherited.viewModel;
}