getPropertyValueFromCondition<R extends Object> static method

R? getPropertyValueFromCondition<R extends Object>(
  1. BaseNode node,
  2. String property, {
  3. required ScopedValues scopedValues,
})

Retrieves the value of a node property from a condition by evaluating the condition if it exists.

Generic type R is the expected return type of the variable value and it must be specified.

scopedValues is required to retrieve the data from various sources.

Implementation

static R? getPropertyValueFromCondition<R extends Object>(
  BaseNode node,
  String property, {
  required ScopedValues scopedValues,
}) {
  final CodelesslyContext? codelesslyContext = scopedValues.codelesslyContext;

  if (codelesslyContext == null) return null;

  final BaseCondition? condition =
      codelesslyContext.conditions.findByNodeProperty(node.id, property);

  // if (condition != null) {
  //   print('----------------------------------------------------------------');
  //   print('CONDITION on ${node.name}-> $property:');
  //   print('----------------------------------------------------------------');
  //   condition.prettyPrint();
  //   print('----------------------------------------------------------------');
  // }
  return condition?.evaluate<R>(scopedValues);
}