getNamed method

Message? getNamed(
  1. List<Node> parts,
  2. String id,
  3. List<String> arguments
)

Implementation

Message? getNamed(
  List<Node> parts,
  String id,
  List<String> arguments,
) {
  final messages = parts
      .where((e) =>
          e.children[0].type == ST.identifier && e.children[0].value == id)
      .map((e) => e.children.firstWhere((e) => e.type == ST.message))
      .map((e) => MessageParser.parseNode(e, arguments))
      .whereType<Message>();
  if (messages.isNotEmpty) {
    return messages.first;
  }
  return null;
}