【发布时间】:2022-01-08 10:13:55
【问题描述】:
我一直在我的 Flutter 应用程序中处理 JSON 文件,我想将多个 JSON 数据合并到一个 Listview.builder 和 FutureBuilder 中。就我而言,我有一个音频 JSON 文件和文本 JSON 文件。
var data;
Future<void> getAll() async{
// text JSON
final url1 = "http://api.alquran.cloud/v1/quran/en.asad";
Uri myUri1 = Uri.parse(url1);
final response1 = await http.get(myUri1);
//audio JSON
final url2 = "http://api.alquran.cloud/v1/quran/ar.alafasy";
Uri myUri2 = Uri.parse(url2);
final response2 = await http.get(myUri2);
/* here I want to combine
response = response1 + response2
then add it to data as */
if (response.statusCode == 200) {
data = json.decode(response.body.toString());
} else {
throw Exception('Failed to load text');
}
}
那么我该如何组合这些呢?如果我可以添加两个,我该如何处理更多 JSON 数据?
【问题讨论】: