2020-07-10 15:53:51 +02:00
|
|
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
|
|
|
|
|
|
|
String _convertGrade(String grade) {
|
2021-03-03 00:24:25 +01:00
|
|
|
const conversionTable = {
|
2020-07-10 15:53:51 +02:00
|
|
|
"grade 1": "小1",
|
|
|
|
"grade 2": "小2",
|
|
|
|
"grade 3": "小3",
|
|
|
|
"grade 4": "小4",
|
|
|
|
"grade 5": "小5",
|
|
|
|
"grade 6": "小6",
|
|
|
|
"junior high": "中"
|
|
|
|
};
|
|
|
|
|
2021-03-03 00:24:25 +01:00
|
|
|
print('conversion run: $grade -> ${conversionTable[grade]}');
|
2020-07-10 15:53:51 +02:00
|
|
|
|
2021-03-03 00:24:25 +01:00
|
|
|
return conversionTable[grade];
|
2020-07-10 15:53:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<jisho.KanjiResult> fetchKanji(String kanji) async {
|
|
|
|
final result = await jisho.searchForKanji(kanji);
|
|
|
|
result.taughtIn = _convertGrade(result.taughtIn);
|
|
|
|
return result;
|
|
|
|
}
|