getLatestModel method Null safety

Model getLatestModel(
  1. Store store
)

This is not used directly by the store, but may be used in tests. If you have a store and a StoreConnector, and you want its associated ViewModel, you can do: Model viewModel = storeConnector.getLatestModel(store);

And if you want to build the widget: var widget = (storeConnector as dynamic).builder(context, viewModel);

Implementation

Model getLatestModel(Store store) {
  //
  // The `vm` parameter is recommended.
  if (vm != null) {
    var factory = vm!();
    internalsVmFactoryInject(factory, store.state, store);
    return factory.fromStore() as Model;
  }
  //
  // The `converter` parameter can be used instead of `vm`.
  else if (converter != null) {
    return converter!(store as Store<St>);
  }
  //
  // The `model` parameter is deprecated.
  // ignore: deprecated_member_use_from_same_package
  else if (model != null) {
    // ignore: deprecated_member_use_from_same_package
    internalsBaseModelInject(model!, store.state, store);
    // ignore: deprecated_member_use_from_same_package
    return model!.fromStore() as Model;
  }
  //
  else
    throw AssertionError("View-model can't be created. "
        "Please provide vm or converter parameter.");
}