Skip to content

Latest commit

 

History

History
149 lines (128 loc) · 5.29 KB

README.md

File metadata and controls

149 lines (128 loc) · 5.29 KB

Email verification for Flutter Apps using DART.

👀 Kindly add the repo to Watch list, to get latest updates regarding servers and packages.

TEST SERVERS OBSOLETE : #74 (comment)


Key points :

  • This package allows developers to verify that the provided Email is valid and also an existing one,
  • It is confirmed by sending an OTP to the specified email ID and verify them.

Features!

Key changes:

  • No more static methods, All the methods are based on the class instance.
  • More reliable and understandable method names.
  • Change in parameters.
  • Session name is made mandatory.
  • Additional option to set the OTP length for production servers
  • Enriched log messages
  • Get detailed logs from server when on debug mode.

Steps

  • Initialize the class

EmailAuth emailAuth =  new EmailAuth(sessionName: "Sample session");
  • Pass in the remote server config if present

emailAuth.config(remoteServerConfiguration);

// remoteServerConfiguration : Signature
{
  "server": "server url",
  "serverKey": "serverKey"
}
  • Sending an otp

    Have the method wrapped in a async funtion.
void sendOtp() async {
  bool result = await emailAuth.sendOtp(
      recipientMail: _emailcontroller.value.text, otpLength: 5
      );
  }
  • Validating an otp

    Have the method wrapped in a funtion for better reusablity.
emailAuth.validateOtp(
        recipientMail: _emailcontroller.value.text,
        userOtp: _otpcontroller.value.text)

Usage template example

import 'package:email_auth/email_auth.dart';
...
Inside your stateLess / Statefull widget class
  ...
  
  // Declare the object
  EmailAuth emailAuth;

  @override
  void initState() {
    super.initState();
    // Initialize the package
    emailAuth = new EmailAuth(
      sessionName: "Sample session",
    );

    /// Configuring the remote server
    emailAuth.config(remoteServerConfiguration);
  }

  final TextEditingController _emailController = TextEditingController();
  final TextEditingController _otpController = TextEditingController();

  /// a Boolean function to verify if the Data provided is true
  bool verify() {
    print(emailAuth.validateOtp(
        recipientMail: _emailcontroller.value.text,
        userOtp: _otpcontroller.value.text));
  }

  /// a void funtion to send the OTP to the user
  /// Can also be converted into a Boolean function and render accordingly for providers
  void sendOtp() async {
    bool result = await emailAuth.sendOtp(
        recipientMail: _emailcontroller.value.text, otpLength: 5);
    if (result) {
      // using a void function because i am using a 
      // stateful widget and seting the state from here.
      setState(() {
        submitValid = true;
      });
    }
  }
  
  ...
   Widget build(BuildContext context) {
   /// have your controllers assigned to textFields or textFormFields
   ...
    body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              controller: _emailController,
            ),
            TextField(
              controller: _otpController,
            ),
          ],
        ),
      ),
      ...

Reference

Property Type Description
EmailAuth Class The parent Class
EmailAuth.sessionName String The sessionName of the instance to be used
EmailAuth.config Boolean Function Used to verify whether the remote server is valid
EmailAuth.sendOtp Boolean Function Takes care of sending OTP to the mail id provided
recipientMail param of EmailAuth.sentOtp() method email ID of the recipient
otpLength param of EmailAuth.sentOtp() method : Defaults to 6 length of the otp
EmailAuth.validateOtp Boolean Function Takes care of verifying the OTP entered by the user

Notable issues / feature requests / Contributions

Privacy Policy 😸

We never share the email ID's we get to any service, nor do we use them for our purposes, we regularly clean up the sent mail section, and we never save any data on our servers, we work on the main motive to be OPEN SOURCE , If so you have any queries kindly mail me at the email ID provided Always happy to answer.

⭐ If you like the package, a star to the repo will mean a lot.

Also feel free to fork the main branch and add some additional features, Will be eager to verify and add the updates.

Thankyou ❤️