SearchItem.fromViewItem constructor
SearchItem.fromViewItem(
- ViewItem viewItem, {
- TranslationLanguage? translationLanguage,
Implementation
factory SearchItem.fromViewItem(
ViewItem viewItem, {
TranslationLanguage? translationLanguage,
}) {
final targetCode = viewItem.targetCode;
final word = viewItem.word;
final supNo = viewItem.supNo;
final pos = viewItem.pos;
final link = viewItem.link;
String? origin = viewItem.origins.map((e) => e.originalLanguage).join();
if (origin.isEmpty) origin = null;
final wordGrade = viewItem.wordGrade;
String? pronunciation =
viewItem.pronunciations.map((e) => e.pronunciation).join("/");
if (pronunciation.isEmpty) pronunciation = null;
final senses = viewItem.senses
.mapIndexed(
(index, senseInfo) => Sense.fromSenseInfo(
senseInfo,
order: index + 1,
),
)
.toList();
return SearchItem(
targetCode: targetCode,
word: word,
supNo: supNo,
pos: pos,
link: link,
wordGrade: wordGrade,
origin: origin,
pronunciation: pronunciation,
senses: senses,
);
}