setSpecification method

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

Implementation

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

  for (final segment in spec.segments) {
    if (!requestIterator.moveNext()) {
      remainingPath = "";
      return;
    }
    final requestSegment = requestIterator.current;

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