From 8ade0dd69fa4f5e3047f6c5983b54645ef2db05f Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Tue, 20 Feb 2024 12:14:21 +0530 Subject: [PATCH] removed focus when any button is clicked --- lib/signup_screen.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/signup_screen.dart b/lib/signup_screen.dart index 8f8e3b9..8aedef6 100644 --- a/lib/signup_screen.dart +++ b/lib/signup_screen.dart @@ -94,6 +94,14 @@ class SignUpPageState extends State { super.dispose(); } + void removeFocusFromAllInputFields() { + _kilvishTextFocus.unfocus(); + _phoneTextFocus.unfocus(); + _emailTextFocus.unfocus(); + _otpEmailTextFocus.unfocus(); + _otpPhoneTextFocus.unfocus(); + } + void allowFormSubmission(int stepNumber) { setState(() { _stepNumber = stepNumber + 1; @@ -176,6 +184,7 @@ class SignUpPageState extends State { isActive: _stepNumber == 3 && (!sendOtpSuccess), isOperationAllowedButNotActive: _stepNumber > 3, buttonClickHandler: () { + removeFocusFromAllInputFields(); verifyUser(); setState(() { _stepNumber = 4; @@ -257,6 +266,7 @@ class SignUpPageState extends State { minimumSize: const Size.fromHeight(50), shape: greyBorderIfNeeded), onPressed: () { + removeFocusFromAllInputFields(); verifyOtp(); }, child: const Text("Verify OTP", @@ -421,6 +431,14 @@ class SignupFormState extends State { ), ]); + 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; }