email_auth 0.0.1+1 copy "email_auth: ^0.0.1+1" to clipboard
email_auth: ^0.0.1+1 copied to clipboard

outdated

A Flutter package to verify emails using OTP, the service will help you verify the emails provided to you are valid and genuine ones, so we don't get random data stored in our Databases, and also prev [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:email_auth/email_auth.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool submitValid = false;
  final TextEditingController _emailcontroller = TextEditingController();
  final TextEditingController _otpcontroller = TextEditingController();
  @override
  void initState() {
    super.initState();
  }

  void verify() {
    print(EmailAuth.validate(
        recieverMail: _emailcontroller.value.text,
        userOTP: _otpcontroller.value.text));
  }

  void sendOtp() async {
    EmailAuth.sessionName = "Company Name";
    bool result =
        await EmailAuth.sendOtp(recieverMail: _emailcontroller.value.text);
    if (result) {
      setState(() {
        submitValid = true;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Email Auth sample'),
        ),
        body: Center(
            child: Center(
          child: Column(
            children: <Widget>[
              TextField(
                controller: _emailcontroller,
              ),
              Card(
                margin: EdgeInsets.only(top: 20),
                elevation: 6,
                child: Container(
                  height: 50,
                  width: 200,
                  color: Colors.green[400],
                  child: GestureDetector(
                    onTap: sendOtp,
                    child: Center(
                      child: Text(
                        "Request OTP",
                        style: TextStyle(
                          fontWeight: FontWeight.bold,
                          color: Colors.white,
                          fontSize: 20,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
              (submitValid)
                  ? TextField(
                      controller: _otpcontroller,
                    )
                  : Container(height: 1),
              (submitValid)
                  ? Container(
                      margin: EdgeInsets.only(top: 20),
                      height: 50,
                      width: 200,
                      color: Colors.green[400],
                      child: GestureDetector(
                        onTap: verify,
                        child: Center(
                          child: Text(
                            "Verify",
                            style: TextStyle(
                              fontWeight: FontWeight.bold,
                              color: Colors.white,
                              fontSize: 20,
                            ),
                          ),
                        ),
                      ),
                    )
                  : Container(
                      height: 1,
                    )
            ],
          ),
        )),
      ),
    );
  }
}
167
likes
0
points
382
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package to verify emails using OTP, the service will help you verify the emails provided to you are valid and genuine ones, so we don't get random data stored in our Databases, and also prevent misusing our app.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on email_auth

Packages that implement email_auth