getLatestModel method
Model
getLatestModel(
- 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 internalsVmFactoryFromStore(factory) as Model;
}
//
// The `converter` parameter can be used instead of `vm`.
else if (converter != null) {
return converter!(store as Store<St>);
}
//
else
throw AssertionError("View-model can't be created. "
"Please provide the vm or the converter parameter.");
}