viewModelOf<T extends EmpireViewModel> method Null safety

T viewModelOf<T extends EmpireViewModel>(
  1. BuildContext context
)

Gets the EmpireViewModel from the EmpireApp that matches the generic type argument T.

This method can be called from any widget below this one in the widget tree. (Example: from a child widget):

Empire.viewModelOf<MyApplicationViewModel>().logOut();

Implementation

static T viewModelOf<T extends EmpireViewModel>(BuildContext context) {
  final EmpireApp<T> result = of(context);
  return result.viewModel();
}