getElementIndex function

int getElementIndex(
  1. Assertion? policy,
  2. String elementName
)

getElementIndex returns the index of a specific element. policy the policy. For example: policy.value = "sub, obj, act" elementName the element's name. For example: elementName = "act" return the index of a specific element. If the above two example parameters are passed in, it will return 2. -1 if the element does not exist.

Implementation

int getElementIndex(Assertion? policy, String elementName) {
  var tokens = splitCommaDelimited(policy?.value);
  var i = 0;
  for (var token in tokens!) {
    if (token == elementName) {
      return i;
    }
    i++;
  }
  return -1;
}