[英]How can I get the headers from the API response in flutter
所以如果響應是 {['myHeader': 'myData']}。
我怎樣才能得到'myHeader'。
FutureBuilder(
future: api_response,
builder: (context, snapshot){
return Text(snapshot.data[0]['myHeader']);
},
)
這是我用來獲取“myData”的代碼。
提前致謝
請嘗試測試下面的代碼。 當快照有數據時,您需要返回 Widget。
FutureBuilder(
future: api_response,
builder: (context, snapshot){
if (snapshot.hasData) {
return Text(snapshot.data[0]['myHeader']);
}
},
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.