flutter_otp

Last updated:

0 purchases

flutter_otp Image
flutter_otp Images
Add to Cart

Description:

flutter otp

flutter_otp #
A Flutter package for Android and iOS for sending and verifying OTP to a Phone number.
Important message for existing Users #
NEW FEATURE !!
Now you can send the message to any country code passed as a parameter to the interface (sendOtp() function)
Installing #
Use this package as a library #
1. Depend on it #
Add this to your package's pubspec.yaml file:
dependencies:
flutter_otp: ^0.3.2
copied to clipboard
2. Install it #
You can install packages from the command line:
with Flutter:
$ flutter packages get
copied to clipboard
Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.
3. Import it #
Now in your Dart code, you can use:
import 'package:flutter_otp/flutter_otp.dart';
copied to clipboard
Functions #
The important functions used in the package are :

sendOtp() to send a OTP (four digit by default, but customizable):

void sendOtp(String phoneNumber, [String messageText]) {
...
}
copied to clipboard

NOTE:

10 digit phoneNumber should be passed.
parameter "messageText" is optional. By default the message text is "Your OTP is : XXXX". If "messageText" parameter is passed then message is sent as "



resultChecker() which takes the OTP entered by the user as a parameter. The function returns true if OTP is matched, else false is returned.

bool resultChecker(int enteredOtp) {
...
}
copied to clipboard

NOTE: The OTP entered by user (say, through TextField widget or TextFormField widget etc) is to be passed as a parameter to this function.

Usage #
To use this package in your application you need to have a sim card in your mobile.
Example Usage:
...
sendOtp('958347XXXX'); //Pass phone number as String

...

int enteredOtp;
TextField(
onChanged: (val) {
enteredOtp = val;
}
)

...

bool isCorrectOTP = resultChecker();
if(isCorrectOTP) {
print('Success');
} else {
print('Failure');
}
...
copied to clipboard
OR custom "messageText" can be passed as parameter to sendOTP
...
sendOtp('958347XXXX', 'OTP is : '); //Pass phone number and Custom messaseText as String

...

int enteredOtp;
TextField(
onChanged: (val) {
enteredOtp = val;
}
)

...

bool isCorrectOTP = resultChecker();
if(isCorrectOTP) {
print('Success');
} else {
print('Failure');
}
...
copied to clipboard
Contributors #

Fawaz Hussain
Jerin Francis

⭐ the repo to show support!
More Information #
Pub package
Flutter documentation.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.