resolve method

RouteParamConfig resolve(
  1. ParameterElement parameterElement
)

Implementation

RouteParamConfig resolve(ParameterElement parameterElement) {
  final paramType = parameterElement.type;
  if (paramType is _dartType.FunctionType) {
    return _resolveFunctionType(parameterElement);
  }
  var type = _typeResolver.resolveType(paramType);

  var pathParam = pathParamChecker.hasAnnotationOfExact(parameterElement);
  String? paramAlias;
  if (pathParam) {
    paramAlias = pathParamChecker
        .firstAnnotationOf(parameterElement)
        ?.getField('name')
        ?.toStringValue();
  }
  var isQuery = queryParamChecker.hasAnnotationOfExact(parameterElement);
  if (isQuery) {
    paramAlias = queryParamChecker
        .firstAnnotationOf(parameterElement)
        ?.getField('name')
        ?.toStringValue();
  }

  return RouteParamConfig(
    type: type,
    isNamed: parameterElement.isNamed,
    name: parameterElement.name.replaceFirst("_", ''),
    alias: paramAlias,
    isPositional: parameterElement.isPositional,
    isRequired: !parameterElement.isOptional,
    isPathParam: pathParam,
    isQueryParam: isQuery,
    isOptional: parameterElement.isOptional,
    defaultValueCode: parameterElement.defaultValueCode,
  );
}