lib/word_search: calculate isCommon

This commit is contained in:
2025-05-14 20:59:57 +02:00
parent 8299572225
commit b07fc8f4b3
3 changed files with 36 additions and 0 deletions
@@ -10,6 +10,9 @@ class WordSearchResult {
/// The ID of the entry in the database.
final int entryId;
/// Whether the word is common or not.
final bool isCommon;
/// The variants of the word in Japanese.
final List<WordSearchRuby> japanese;
@@ -30,6 +33,7 @@ class WordSearchResult {
const WordSearchResult({
required this.entryId,
required this.isCommon,
required this.japanese,
required this.kanjiInfo,
required this.readingInfo,
@@ -40,6 +44,7 @@ class WordSearchResult {
Map<String, dynamic> toJson() => {
'entryId': entryId,
'isCommon': isCommon,
'japanese': japanese.map((e) => e.toJson()).toList(),
'kanjiInfo':
kanjiInfo.map((key, value) => MapEntry(key, value.toJson())),
@@ -53,6 +58,7 @@ class WordSearchResult {
factory WordSearchResult.fromJson(Map<String, dynamic> json) =>
WordSearchResult(
entryId: json['entryId'] as int,
isCommon: json['isCommon'] as bool,
japanese: (json['japanese'] as List<dynamic>)
.map((e) => WordSearchRuby.fromJson(e))
.toList(),