OTP Service

A Dart package for sending and verifying OTPs (One-Time Passwords) using an external API. This package is designed to be simple and easy to integrate into Flutter apps.

Features

  • Send OTP to a phone number.
  • Verify OTP for a given phone number.

Installation

Add the following to your pubspec.yaml file:

dependencies:
  smssak: ^1.0.0

Then, run flutter pub get to install the package.

Usage

Sending an OTP

To send an OTP, use the sendOtp method:

import 'package:smssak/smssak.dart';

void main() async {
  final otpService = OTPService();

  final response = await otpService.sendOtp(
    country: 'dz', // 2-letter country code
    projectId: 'your_project_id', // Your project ID
    phone: '1234567890', // Phone number to send OTP to
    key: 'your_api_key', // Your API key
  );

  print('OTP Sent: $response');
}

Verifying an OTP

To verify an OTP, use the verifyOtp method:

import 'package:smssak/smssak.dart';

void main() async {
  final otpService = OTPService();

  final response = await otpService.verifyOtp(
    country: 'dz', // 2-letter country code
    projectId: 'your_project_id', // Your project ID
    phone: '1234567890', // Phone number to verify
    otp: '123456', // OTP to verify
    key: 'your_api_key', // Your API key
  );

  print('OTP Verified: $response');
}

Libraries

smssak
Support for doing something awesome.