How can i add circular progress indicator on "onPressed" in the follwing code?
Here is a solution, use setState to implement circular progress bar
bool isloading=false;
child: !isloading ? RaisedButton(
color: AppColors.darkGreenColor,
onPressed: () async{
if(passwordController.text == '' ||phoneNumber.text == '')
{Get.snackbar("Please Enter Mobile or Password", '',colorText: Colors.white,backgroundColor: AppColors.darkGreenColor);
}
if(_formKey.currentState!.validate() && passwordController.text!=''){
_formKey.currentState!.save();
setState(() {
isloading=true;
});
await loginUser();
setState(() {
isloading=false;
isloading=!isloading;
});
}
},
child: Text(AppString.login,
style:AppTextStyles.appTextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white
)
),
): Center(child: CircularProgressIndicator())
),