I am writing to you for support on Getx.
I currently have a GetView class where there is a button that needs to call a method defined inside the controller.
This method makes a call to a server and then after the call, it must show a BottomSheet.
Unfortunately, and I think this is my limit on GETX, I noticed that the BottomSheet is shown immediately without waiting for the response from the backend.
I tried with the wait but unfortunately without success.
Is there any tutorial I can view?
Thank you all.
Code method controller
Future<bool> increaseWallet() async {
try{
await MangoPay.instance.makePayment(
mangoPayUserId: user!.mangoPayId!,
mangoPayPaymentWalletId: user!.walletId!,
cardData: _cardData, amount: double.parse(amount),
paymentCallback: (result, message, transactionId, status) async {
if(status=="SUCCEEDED"){
hideLoader();
_bContinue = true;
}
});
}
catch(e){
hideLoader();
return bContinue;
}
finally {
hideLoader();
}
return bContinue;
}
Page
SizedBox(
width: double.infinity,
child: PrimaryButtonBG(
text: 'Ricarica wallet',
onTap: () {
controller.increaseWallet().then((bContinue){
openSuccessWallet(context);
});
},
),
),
4
Answers
If you want to wait you should use this Future. delay(Duration(Xyz)) or Timer function
Easiest way is using workers, for example:
if you want to update UI with Getx, there are 2 ways:
"_bContinue = true;"
the UI will updatevoid showBottomSheet() { _bContinue = true; update(); }
status == 'SUCCEEDED'