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 executedValue = value.execute(results.toList(), passed);
  return value.length != 1 || value.first is! IntegerParser
      ? throw FhirPathEvaluationException(
          'The argument passed to the .take() function was not valid:',
          operation: '.take()',
          arguments: value)
      : executedValue.first is! int
          ? throw FhirPathEvaluationException(
              'The value for .take() was not a number: $value',
              operation: '.take()',
              arguments: value)
          : executedValue.first <= 0 ||
                  results.isEmpty ||
                  executedValue.first >= results.length
              ? results
              : results.sublist(0, executedValue.first);
}