2020-06-30 13:28:07 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2020-06-30 16:27:19 +02:00
|
|
|
import 'package:unofficial_jisho_api/api.dart' as jisho;
|
2020-06-30 13:28:07 +02:00
|
|
|
|
2020-07-11 13:37:46 +02:00
|
|
|
import 'package:jisho_study_tool/components/kanji/kanji__search_page/kanji_search_page.dart';
|
|
|
|
import 'package:jisho_study_tool/services/kanji_search.dart';
|
2020-06-30 13:28:07 +02:00
|
|
|
|
2020-06-30 16:27:19 +02:00
|
|
|
Widget searchForKanji(String kanji) {
|
|
|
|
return FutureBuilder(
|
2020-07-10 15:53:51 +02:00
|
|
|
future: fetchKanji(kanji),
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<jisho.KanjiResult> snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
return KanjiResultCard(snapshot.data);
|
|
|
|
} else if (snapshot.hasError) {
|
|
|
|
throw 'ASYNC ERROR';
|
|
|
|
} else {
|
|
|
|
return Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
2020-07-09 18:14:17 +02:00
|
|
|
}
|