setSpecification method Null safety

void setSpecification(
  1. RouteSpecification spec,
  2. {int segmentOffset = 0}
)

Implementation

void setSpecification(RouteSpecification spec, {int segmentOffset = 0}) {
  var requestIterator = segments.iterator;
  for (var i = 0; i < segmentOffset; i++) {
    requestIterator.moveNext();
  }

  for (var segment in spec.segments) {
    requestIterator.moveNext();
    var requestSegment = requestIterator.current;

    if (segment.isVariable) {
      variables[segment.variableName!] = requestSegment;
      orderedVariableNames.add(segment.variableName!);
    } else if (segment.isRemainingMatcher) {
      var remaining = [];
      remaining.add(requestIterator.current);
      while (requestIterator.moveNext()) {
        remaining.add(requestIterator.current);
      }
      remainingPath = remaining.join("/");

      return;
    }
  }
}