getPropertyInView function
Expression
getPropertyInView(
- Expression property,
- CompileView? callingView,
- CompileView definedView
Implementation
o.Expression getPropertyInView(
o.Expression property,
CompileView? callingView,
CompileView definedView,
) {
if (identical(callingView, definedView)) {
return property;
} else {
o.Expression? viewProp;
var currView = callingView;
while (!identical(currView, definedView) &&
currView?.declarationElement.view != null) {
currView = currView?.declarationElement.view!;
viewProp = viewProp == null
? o.ReadClassMemberExpr('parentView')
: viewProp.prop('parentView');
viewProp = viewProp.notNull();
}
if (!identical(currView, definedView)) {
throw StateError(
'Internal error: Could not calculate a property '
'in a parent view: $property',
);
}
// Don't cast properties of `RenderView`.
return replaceReadClassMemberInExpression(
property,
(name) => _renderViewProperties.contains(name)
? viewProp!
: unsafeCast(viewProp!, definedView.classType),
);
}
}