Phone Verification

This package helps the flutter developer to send OTP to the user and verify user's Phone Number.
⭐It is recommended to use this package with real device and not emulator
⚠ Currently it only works on Android.

Features

πŸ‘‰ Free OTP Verification System.
πŸ‘‰ Reliable
πŸ‘‰ 4 digit OTP

Demo

πŸ˜… I am hide my number due to privacy issue

Android

  • Inside android/app/build.gradle file change following sdks
    compileSdkVersion 31 //change to 31

 

    defaultConfig {
       --------------------------------------
        --------------------------------------
        minSdkVersion 21 //change to 21
        targetSdkVersion 30 //change to 30
        --------------------------------------
        --------------------------------------
    }

  • Inside android/app/src/main/AndroidManifest.xml add the following two lines
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mysql_register">
  <!-- add these lines πŸ‘‡ -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.SEND_SMS" />
 <!-- add these lines πŸ‘† -->
   <application

Installation

  • First, add the latest phone_verification package to your pubspec dependencies.
dependencies:
  phone_verification: ^0.0.1
  • Second import package to your file
import 'package:phone_verification/phone_verification.dart'
  • Call the Instance of PhoneVerification class
  PhoneVerification phoneverification = PhoneVerification(number: usernumber);
//here usernumber is the Phone number which is to be verified

Send OTP

πŸ‘‰ In the following codes usernumber should be use without country code and Your Otp is the message I want to send with the OTP, you can change that according to your choice.

  PhoneVerification phoneverification = PhoneVerification(number:'93514xxxxx' );
  
  phoneverification.sendotp('Your Otp');

or

PhoneVerification(number: '93514xxxxx').sendotp('Your Otp');

Verify OTP

πŸ‘‰ Pass the OTP entered by the user to verifyotp() method here enteredotpis the user typed OTP.

String check= 'No acion';

ElevatedButton(
 onPressed: () async {
    
     //write the below line to verify
    
     bool verify = await PhoneVerification(number: '93514xxxxx').verifyotp(enteredotp.toString());
    
    //if verified successfully it will return true else return false
    
    if (verify == true) {
         check = 'Verify';
     } 

     else {
         check = 'error';
     }
        },
child: Text("Tap To Verify")),

or

String check= 'No acion';
 ElevatedButton(
  onPressed: () async {
     //write the below line to verify
    
    PhoneVerification phoneverification = PhoneVerification(number: '93514xxxxx');
     bool verify = await phoneverification.verifyotp(enteredotp.toString());
    
    
     //if verified successfully it will return true else return false
    
     check = verify == true ? 'verify' : 'error';
   }
 child: Text("Tap To Verify")),

Libraries

phone_verification