getDefaultValueCode method

String? getDefaultValueCode(
  1. ParameterElement parameter
)

Implementation

String? getDefaultValueCode(
  ParameterElement parameter,
) {
  final constructor = parameter.enclosingElement as ConstructorElement;
  if (parameter.hasDefaultValue) {
    return parameter.defaultValueCode;
  }
  if (constructor.redirectedConstructor != null) {
    final redirectedParameter =
        constructor.redirectedConstructor!.parameters.firstWhereOrNull(
      (element) => element.name == parameter.name,
    );

    if (redirectedParameter != null) {
      return getDefaultValueCode(redirectedParameter);
    }
  }
}