register<TModel extends Pub> static method
Register the consumer widget context
to the Host with aspects
,
and add these aspects
to regAspects
.
Return the TModel
Implementation
static TModel register<TModel extends Pub>(
BuildContext context, {
Iterable<Object>? aspects,
}) {
assert(ifModelTypeCorrect(TModel, 'Host.register'));
if (aspects == null || aspects.isEmpty) {
final inheritedModel =
InheritedMediator.inheritFrom<InheritedMediator<TModel>>(context);
assert(ifInheritedModel<TModel>(inheritedModel));
final model = inheritedModel!._model;
// aspects is null, no need to `addRegAspects`
return model;
}
final inheritedModel =
InheritedMediator.inheritFrom<InheritedMediator<TModel>>(context,
aspect: aspects);
assert(ifInheritedModel<TModel>(inheritedModel));
final model = inheritedModel!._model;
/// Add [aspects] to the registered aspects of the model
// if (aspects != null) {
model.regAspects.addAll(aspects);
// }
return model;
}