maybeFindProperty<T> static method
Find and listen to property changes of the data with the given type from the context. Throws an assertion error if the data is not found.
TThe type of the data.contextThe build context.keyThe data key.
Implementation
static ModelProperty<T>? maybeFindProperty<T>(
BuildContext context, Symbol key) {
final widget = context.findAncestorWidgetOfExactType<_InheritedModel>();
if (widget == null) {
return null;
}
for (final model in widget.data) {
if (model.dataKey == key && model.dataType == T) {
if (model is ModelBoundary<T>) {
return null;
}
return model as ModelProperty<T>;
}
}
return null;
}