0 purchases
otp detection flutter
otp_detection_flutter_example #
Daily, we use OTP for account verification for bank transactions to the normal login mobile verification Depending upon the usage the length of the OTP may differ,
this variation is because of security for transactions added we have the timer for OTP, so the auto-fill OTP is a mandatory feature for every app,
for iOS, the auto fill is the default feature but in android, we need that, this plugin fulfills the need.
Getting Started #
PinFieldAutoFill
TextFieldPinAutoFill
copied to clipboard
##To listen for the SMS with the code.
await OtpDetect().listenForCode();
copied to clipboard
This will listen for the SMS with the code during 5 minutes and when received, autofill the following widget.
##PinFieldAutoFill
PinFieldAutoFill(
decoration: // UnderlineDecoration, BoxLooseDecoration or BoxTightDecoration see https://github.com/TinoGuo/pin_input_text_field for more info,
currentCode: // prefill with a code
onCodeSubmitted: //code submitted callback
onCodeChanged: //code changed callback
codeLength: //code length, default 6
),
copied to clipboard
##TextFieldPinAutoFill
TextFieldPinAutoFill(
decoration: // basic InputDecoration
currentCode: // prefill with a code
onCodeSubmitted: //code submitted callback
onCodeChanged: //code changed callback
codeLength: //code length, default 6
),
copied to clipboard
##Android SMS constraint
For the code to be receive, it need to follow some rules as describe here:
https://developers.google.com/identity/sms-retriever/verify
Be no longer than 140 bytes
Contain a one-time code that the client sends back to your server to complete the verification flow
End with an 11-character hash string that identifies your app
One example of SMS would be:
ExampleApp: Your code is 123456
FA+9qCX9VSu
copied to clipboard
Custom CodeAutoFill
If you want to create a custom widget that will autofill with the sms code, you can use the CodeAutoFill mixin that will offer you:
listenForCode() to listen for the SMS code from the native plugin when SMS is received, need to be called on your initState.
cancel() to dispose the subscription of the SMS code from the native plugin, need to be called on your dispose.
codeUpdated() called when the code is received, you can access the value with the field code.
unregisterListener() to unregister the broadcast receiver, need to be called on your dispose.
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.