I've this code in a Flutter page.
This code is supposed to show to the user that his orders had been send to the database.
I use a future with the function .then and I should get the response status code 200 which is printed in the debug console of my app.
Does someone know why my _textInfo String variable doesn't take the future as new value ?
Container(
padding: const EdgeInsets.all(Pages.edgeInsetsAll),
child: ElevatedButton(
onPressed: () {
setState(() {
for (int i = 0; i < myb.length; i++) {
if (myb[i].count > 1) {
for (int j = 0; j < myb[i].count; j++) {
postOrder(
widget.basketId,
Session.sessionQRCode,
"Pas Membre",
"Especes",
Session.sessionEstaName,
myb[i].price,
myb[i].product,
myb[i].add).then((value) {
_textInfo = 'ORDER : $value';
});
}
} else {
postOrder(
widget.basketId,
Session.sessionQRCode,
"Pas Membre",
"Especes",
Session.sessionEstaName,
myb[i].price,
myb[i].product,
myb[i].add).then((value){
_textInfo= 'ORDER : $value';
});
}
}
myb.clear();
});
},
child: Text(_textInfo)),
),