getParentProp method
Prop<dynamic, T>
getParentProp(
)
Implementation
Prop<dynamic, T> getParentProp() {
final parent = $parent;
final prop = parent.getKind().props.singleWhere((prop) {
return prop.isFieldIdenticalTo(parent, this);
}, orElse: () {
throw StateError(
'Could not find property in the EntityKind.\n'
'\n'
'Make sure your class looks like the following:/\n'
' class YourClass extends Entity {/\n'
' static final EntityKind<YourClass> kind = EntityKind<YourClass>(\n'
' define: (c) {\n'
' // ...\n'
' c.addProp(Prop<YourClass, YourFieldType>(\n'
' id: 42,\n'
' name: \'yourField\',\n'
' field: (e) => e.yourField, // <---- IMPORTANT\n'
' kind: YourFieldKind(),\n'
' ));\n'
' },\n'
' );\n'
' // ...\n'
' late final Field<YourFieldType> yourField = Field<YourFieldType>(this);\n'
' // ...\n'
' @override\n'
' EntityKind<YourClass> getKind() => kind;\n'
' }\n',
);
});
return prop as Prop<dynamic, T>;
}