execute method Null safety

List execute(
  1. List results,
  2. Map<String, dynamic> passed
)
override

Implementation

List execute(List results, Map<String, dynamic> passed) {
  final passedValue = passed[value];
  if (passedValue == null) {
    throw FhirPathEvaluationException('Variable $value does not exist.',
        variables: passed);
  }

  if (passedValue is! Function()) {
    return passedValue is List ? passedValue : [passedValue];
  } else {
    try {
      final result = passedValue();

      return result is List ? result : [result];
    } catch (ex) {
      throw FhirPathEvaluationException(
          'Variable $value could not be lazily evaluated.',
          cause: ex);
    }
  }
}