generateMessageCall method
Implementation
Method? generateMessageCall(int index, MessageWithMetadata message) {
if (!message.nameIsDartConform) {
return null;
}
final arguments =
message.placeholders.map((placeholder) => placeholder.name).join(', ');
final indexStr = options.indexType == IndexType.enumerate
? '${enumName(context)}.${message.name}.index'
: index.toString();
final body =
'_currentMessages.generateStringAtIndex($indexStr, [$arguments])';
final methodType = message.placeholders.isEmpty ? MethodType.getter : null;
return Method(
(mb) => mb
..type = methodType
..name = message.name
..lambda = true
..returns = const Reference('String')
..requiredParameters.addAll(
message.placeholders.map(
(placeholder) => Parameter(
(pb) => pb
..type = Reference(placeholder.type)
..name = placeholder.name,
),
),
)
..body = Code(body),
);
}