expandGenerators method

String? expandGenerators(
  1. _FieldAnnotation annotation, {
  2. required FieldElement field,
  3. required SharedChecker<Model> checker,
})

Convert placeholders in fromGenerator and toGenerator to functions.

Implementation

String? expandGenerators(
  _FieldAnnotation annotation, {
  required FieldElement field,
  required SharedChecker checker,
}) {
  final name = providerNameForField(annotation.name, checker: checker);

  if (doesDeserialize && annotation.fromGenerator != null) {
    return digestPlaceholders(annotation.fromGenerator, name, field.name);
  }

  if (!doesDeserialize && annotation.toGenerator != null) {
    return digestPlaceholders(annotation.toGenerator, name, field.name);
  }

  return null;
}