buildParameter method Null safety

Parameter buildParameter(
  1. String fieldName
)

Implementation

Parameter buildParameter(String fieldName) {
  final parameterName = fieldName.camelCase;
  return Parameter(
    (b) => b
      ..annotations.add(
        InvokeExpression.newOf(
          const Reference(
            'JsonKey',
            'package:freezed_annotation/freezed_annotation.dart',
          ),
          const [],
          ({
            'name': literalString(fieldName),
            'fromJson': fromJsonFunctionReference?.expression,
            'toJson': toJsonFunctionReference?.expression,
          }..removeWhere((key, value) => value == null))
              .cast(),
        ),
      )
      ..named = true
      ..required = !optional
      ..name = parameterName
      ..type = computeReference(fieldName),
  );
}