@override
Widget build(BuildContext context) {
widget.groupid;
widget.event_id;
var futureBuilder = new FutureBuilder(
future: _getAllTickets(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
print(snapshot.connectionState);
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return new Text('...');
default:
if (snapshot.hasError)
return new Text('Error: ${snapshot.error}');
else
return createListTickets(context, snapshot);
}
},
);
return new Scaffold(
body: futureBuilder,
);
}
Widget createListTickets(BuildContext context, AsyncSnapshot snapshot) {
List values = snapshot.data;
child: new Card(
child:
new Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
new Text(
values[index]["ticket_type_id"].toString(), style:
const TextStyle(
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
fontSize: 25.0)),
}
_getAllTickets() async {
final response = await http.get(
"https...}"
, headers: {
HttpHeaders.AUTHORIZATION: access_token
});
returnTickets = json.decode(response.body);
return returnTickets;
}
_getTicketType() async {
for (i = 0; i < (returnTickets?.length ?? 0); i++) {
/*print("https....);*/
final responseType = await http.get(
"https...}"
, headers: {
HttpHeaders.AUTHORIZATION: access_token
});
Map<String, dynamic> hey = json.decode(responseType.body);
}
大家好,我有一个问题。由于我正在发送多个API请求并根据返回的响应动态构建一个卡片,我想知道是否可以在future中包含不止一个方法:_getAllTickets() +(另一个方法),因为我想用方法_getTicketType()获得的新索引响应“名称”替换values[index] [“ticket_type_id”]中的值。 提前感谢!