getPassage method
Queries the bibleapi.
Implementation
@override
Future<PassageQuery> getPassage(BibleReference query,
{Map<String, String>? parameters, String? key, String? version}) async {
final params = {
'verse_numbers': '${parameters!['verse_numbers'] ?? 'false'}',
'translation': "${version ?? 'web'}",
};
final uri = Uri.https('bible-api.com', '/${query.reference}', params);
final res = await http.get(uri);
var json = jsonDecode(res.body);
var versesRaw = json['verses'];
var verses = <String, String?>{};
versesRaw.forEach((x) => {
verses['${x['book_name']} ${x['chapter']}:${x['verse']}'] = x['text'],
});
var reference = query.reference;
var passage = json['text'].trim();
var translation = json['translation_id'].toUpperCase();
return PassageQuery.fromProvider(passage, reference, translation,
verses: verses, extra: json);
}