@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);
}
Hi everyone, I have a question.
As I am sending multiple API request and building dynamically a card with the response that I get in return, I was wondering if I could include more that one method within future: _getAllTickets(), + (another method), as I would like to substitute values[index]["ticket_type_id"] with values[index]["name"], which name is a new index response that I have got through the method _getTicketType().
Thank you in advance!
question from:
https://stackoverflow.com/questions/50626949/can-i-use-multiple-method-on-a-future-builder 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…