getParameters method

Iterable getParameters(
  1. String input
)

Implementation

Iterable<dynamic> getParameters(String input) {
  final stringValues = <String>[];
  final values = <dynamic>[];
  _expression.allMatches(input).forEach(
    (m) {
      // the first group is always the input string
      final indices = List.generate(
        m.groupCount,
        (i) => i + 1,
        growable: false,
      ).toList();

      stringValues.addAll(
        m.groups(indices).where((x) => x != null).cast(),
      );
    },
  );

  final definedParameters = _sortedParameterPositions
      .where((x) => x.parameter.includeInParameterList)
      .toList();

  for (var i = 0; i < stringValues.length; i += 1) {
    final val = stringValues.elementAt(i);
    final cp = definedParameters.elementAt(i);
    if (cp.parameter.includeInParameterList) {
      values.add(cp.parameter.transformer(val));
    }
  }

  return values;
}