treewide: redo handling of kanjidic radicals

This commit is contained in:
2025-05-19 16:40:34 +02:00
parent 60d2017473
commit 31c3fb807e
8 changed files with 97 additions and 50 deletions

View File

@@ -4,37 +4,48 @@ class KanjiSearchRadical extends Equatable {
/// The radical symbol.
final String symbol;
/// The names of this radical.
///
/// Each name might refer to a specific form of the radical.
final List<String> names;
/// The radical forms used in this kanji.
///
/// (e.g. "亻" for "人", "氵" for "水")
final List<String> forms;
/// The meaning of the radical.
final String meaning;
/// The meanings of the radical.
final List<String> meanings;
// ignore: public_member_api_docs
const KanjiSearchRadical({
required this.symbol,
this.forms = const [],
required this.meaning,
required this.names,
required this.forms,
required this.meanings,
});
@override
List<Object> get props => [
symbol,
this.names,
forms,
meaning,
meanings,
];
Map<String, dynamic> toJson() => {
'symbol': symbol,
'names': names,
'forms': forms,
'meaning': meaning,
'meanings': meanings,
};
factory KanjiSearchRadical.fromJson(Map<String, dynamic> json) {
return KanjiSearchRadical(
symbol: json['symbol'] as String,
names: (json['names'] as List).map((e) => e as String).toList(),
forms: (json['forms'] as List).map((e) => e as String).toList(),
meaning: json['meaning'] as String,
meanings: (json['meanings'] as List).map((e) => e as String).toList(),
);
}
}

View File

@@ -49,17 +49,17 @@ class KanjiSearchResult extends Equatable {
const KanjiSearchResult({
required this.kanji,
this.taughtIn,
this.jlptLevel,
this.newspaperFrequencyRank,
required this.taughtIn,
required this.jlptLevel,
required this.newspaperFrequencyRank,
required this.strokeCount,
required this.meanings,
this.kunyomi = const [],
this.onyomi = const [],
required this.kunyomi,
required this.onyomi,
// this.kunyomiExamples = const [],
// this.onyomiExamples = const [],
this.radical,
this.parts = const [],
required this.radical,
required this.parts,
required this.codepoints,
});