Sense.fromXmlElement constructor

Sense.fromXmlElement(
  1. XmlElement data
)

Implementation

factory Sense.fromXmlElement(XmlElement data) {
  final order = int.parse(
    data.getElement(ApiXmlElement.senseOrder.name)!.innerText.trim(),
  );
  final definition =
      data.getElement(ApiXmlElement.definition.name)!.innerText.trim();
  final translationEntries =
      data.findElements(ApiXmlElement.translation.name).map(
    (e) {
      final translation = Translation.fromXmlElement(e);
      return MapEntry(translation.language!,
          DictionaryDefinitionTranslation.fromTranslation(translation));
    },
  );
  final translations = {
    for (final entry in translationEntries) entry.key: entry.value,
  };
  print("test");
  return Sense(
    order: order,
    definition: definition,
    translations: translations,
  );
}