format method

String format()

Implementation

String format() {
  int maxTypeStringLength = _headers.type.length;
  int maxMethodStringLength = _headers.method.length;
  int maxPathStringLength = _headers.path.length;

  for (final route in data) {
    maxTypeStringLength = max(maxTypeStringLength, route.type.length);
    maxMethodStringLength = max(
      maxMethodStringLength,
      route.method.methodString.length,
    );
    maxPathStringLength = max(maxPathStringLength, route.path.length);
  }

  return [
    _formatHeader(
      maxTypeStringLength,
      maxMethodStringLength,
      maxPathStringLength,
    ),
    _formatSeparator(
      maxTypeStringLength,
      maxMethodStringLength,
      maxPathStringLength,
    ),
    for (final route in data)
      _formatRow(
        route,
        maxTypeStringLength,
        maxMethodStringLength,
        maxPathStringLength,
      ),
  ].join('\n');
}