I want to show CircularProgressIndicator until the function end, So I use this method,
-
set bool isLoading = false; -
and this is the function,
verifyPhoneNumber(String input) async { setState(() { isLoading = true; }); await AuthMethods().phoneSign(context, input); setState(() { isLoading = false; });} -
For this screen
Scaffold( body: isLoading ? Center( child: CircularProgressIndicator(color: darkblueColor), ) : Column( children: [ IntlPhoneField( onChanged: (phone) { setState(() { fullNumber = phone.completeNumber; }); }, ), CustomButton( onTap: () { verifyPhoneNumber(fullNumber); }, text: "Next", height: 50, ),],),)
This is not working!. Can futureBuilderapply for this & If it’s yes, How?
this function work for firebase phoneAuth, There is phoneSign inside AuthMethods class.
>Solution :
For question snippet , you need to await for verifyPhoneNumber
Future<void> verifyPhoneNumber(String input) async {
setState(() {
isLoading = true;
});
await AuthMethods().phoneSign(context, input);
setState(() {
isLoading = false;
});}
Make the async method
CustomButton(
onTap: ()async {
await verifyPhoneNumber(fullNumber); // you need to await for future