reduce method
MessagesWithMetadata
reduce(
- MessagesWithMetadata parentFile,
- MessagesWithMetadata inputMessageFile
Only keep the messages which are in the parent file, as only those will get a generated method to embed them in code.
Implementation
MessagesWithMetadata reduce(
MessagesWithMetadata parentFile,
MessagesWithMetadata inputMessageFile,
) {
final messageNames = parentFile.messages.map((e) => e.name).toList();
final messages = inputMessageFile.messages
.where((message) => messageNames.contains(message.name))
.toList()
..sort((a, b) => a.name.compareTo(b.name));
return inputMessageFile.copyWith(messages: messages);
}