Skip to content

Commit

Permalink
removed focus when any button is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Sharma committed Feb 20, 2024
1 parent 554f45a commit 8ade0dd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/signup_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class SignUpPageState extends State<SignUpPage> {
super.dispose();
}

void removeFocusFromAllInputFields() {
_kilvishTextFocus.unfocus();
_phoneTextFocus.unfocus();
_emailTextFocus.unfocus();
_otpEmailTextFocus.unfocus();
_otpPhoneTextFocus.unfocus();
}

void allowFormSubmission(int stepNumber) {
setState(() {
_stepNumber = stepNumber + 1;
Expand Down Expand Up @@ -176,6 +184,7 @@ class SignUpPageState extends State<SignUpPage> {
isActive: _stepNumber == 3 && (!sendOtpSuccess),
isOperationAllowedButNotActive: _stepNumber > 3,
buttonClickHandler: () {
removeFocusFromAllInputFields();
verifyUser();
setState(() {
_stepNumber = 4;
Expand Down Expand Up @@ -257,6 +266,7 @@ class SignUpPageState extends State<SignUpPage> {
minimumSize: const Size.fromHeight(50),
shape: greyBorderIfNeeded),
onPressed: () {
removeFocusFromAllInputFields();
verifyOtp();
},
child: const Text("Verify OTP",
Expand Down Expand Up @@ -421,6 +431,14 @@ class SignupFormState extends State<SignupForm> {
),
]);

if (widget.isActive) {
//this will give focus to the active input field
widget.textFocus.requestFocus();
} else {
//this will give un focus to the in active input field
widget.textFocus.unfocus();
}

return uiWidget;
}

Expand Down

0 comments on commit 8ade0dd

Please sign in to comment.