SearchItem.fromXmlElement constructor
SearchItem.fromXmlElement(
- XmlElement data
"item" xml element.
Implementation
factory SearchItem.fromXmlElement(XmlElement data) {
final targetCode = int.parse(
data.getElement(ApiXmlElement.targetCode.name)!.innerText.trim(),
);
final word = data.getElement(ApiXmlElement.word.name)!.innerText.trim();
final supNo =
int.parse(data.getElement(ApiXmlElement.supNo.name)!.innerText.trim());
final senses = data
.findElements(ApiXmlElement.sense.name)
.map(Sense.fromXmlElement)
.toList();
final link = data.getElement(ApiXmlElement.link.name)!.innerText.trim();
final origin = data.getElement(ApiXmlElement.origin.name)?.innerText.trim();
var aux = data.getElement(ApiXmlElement.wordGrade.name)?.innerText.trim();
final wordGrade = WordGrade.fromHangul(aux ?? '');
final pronunciation =
data.getElement(ApiXmlElement.pronunciation.name)?.innerText.trim();
aux = data.getElement(ApiXmlElement.pos.name)!.innerText.trim();
final pos = PartOfSpeech.fromHangul(aux);
return SearchItem(
targetCode: targetCode,
word: word,
supNo: supNo,
senses: senses,
pos: pos,
link: link,
origin: origin,
wordGrade: wordGrade,
pronunciation: pronunciation,
);
}