constructorParametersValue function

String constructorParametersValue(
  1. ConstructorElement constructor,
  2. int messageIndex, {
  3. Map<DartType, String>? replace,
})

Implementation

String constructorParametersValue(
  final ConstructorElement constructor,
  int messageIndex, {
  Map<DartType, String>? replace,
}) {
  String arg = "";

  for (var par in constructor.parameters) {
    if (replace?.containsKey(par.type) ?? false) {
      arg += par.isNamed
          ? "${par.name}: ${replace![par.type]},"
          : "${replace![par.type]},";

      continue;
    }
    arg += par.isNamed
        ? "${par.name}:message[${messageIndex++}],"
        : "message[${messageIndex++}],";
  }

  return arg;
}