Made otp field text single digit and override text behaviour added#31
Open
shaikhaman2000 wants to merge 8 commits into
Open
Made otp field text single digit and override text behaviour added#31shaikhaman2000 wants to merge 8 commits into
shaikhaman2000 wants to merge 8 commits into
Conversation
Comment on lines
+215
to
+230
| if (str.length == widget.length && index == widget.length - 1) { | ||
| print('Handling Paste'); | ||
| _handlePaste(str); | ||
| return; | ||
| } else { | ||
| if (_pin.length >= index + 1) { | ||
| str = str.replaceFirst(_pin[index], ''); | ||
| } else { | ||
| int len = str.length; | ||
| str = str[len - 1]; | ||
| } | ||
| // Update the current pin | ||
| setState(() { | ||
| _textControllers[index]!.text = str; | ||
| }); | ||
| } |
Owner
There was a problem hiding this comment.
not sure why is this code here and not inside _handlePaste
Author
There was a problem hiding this comment.
- The previous behaviour was not allowing users to override previous individual otp field. What I did here is basically made the field length to 2.
- When users want to paste otp they need to be on the initial field only and the text length should be equal to otp field length (Line number 215)
- if the length is less than or equal to 2, we assume user wants to override previously written text -> We remove replace previous digit from this text and set the text to newly written text (In case of previously its being 2, and user writes 0 -> we replace 2 with '' and set text as 0)
- if the same individual otp field doesn’t contain any text (i.e., user is typing first time) we handle it with line number 222's else block.
- I have added onTap() function to make sure, user stays in the end of otp field to handle back press efficiently. (Previously when the user's cursor was pointing before text, it didn’t allowed erasing the text and wasn’t taking back to previously available field)
Owner
iamvivekkaushik
left a comment
There was a problem hiding this comment.
not merging this, left comments.
Author
|
I will be pushing the changes you suggested above. Thank you. |
Author
|
@iamvivekkaushik Have a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.