otpless_flutter_web 1.2.4 copy "otpless_flutter_web: ^1.2.4" to clipboard
otpless_flutter_web: ^1.2.4 copied to clipboard

A versatile Flutter web package eliminating the need for OTP during user authentication. Simplify secure login workflows effortlessly.

Flutter #

Integrating One Tap OTPLESS Sign In into your Flutter Website using our SDK is a streamlined process. This guide offers a comprehensive walkthrough, detailing the steps to install the SDK and seamlessly retrieve user information.

  1. Install OTPless SDK Dependency
flutter pub add otpless_flutter_web:1.2.4
  1. Initialize Otpless in index.html
<!-- Add this script to initiate otpless -->
<script
  data-appid="{YOUR_APP_ID}"
  src="https://otpless.com/v2/flutter.js"
  id="otpless-sdk"
  type="text/javascript"
  variant="HEADLESS"
></script>
  1. Configure Sign up/Sign in
  • Import the following classes.
import 'package:otpless_flutter_web/otpless_flutter_web.dart';
  • Add this code to your initState() method
@override
  void initState() {
    _otplessFlutterPlugin.headlessResponse().then((value) {
      print("responseData : $value");
    });
    super.initState();
}
  • Add this code for OAUTH Authentication
void initiateOAuth(String channelType) async {
    await _otplessFlutterPlugin.initiateOAuth(channelType).then((value) {
      print("initiateOAuth : $value");
    });
}
  • Add this code for PHONE/EMAIL Authentication
void initiatePhoneEmailAuth() async {
    Map<String, dynamic> arg = {};
    if (otpContoller.text.isNotEmpty) {
      if (phoneNumberContoller.text.isNotEmpty) {
        arg["phone"] = phoneNumberContoller.text;
        arg["countryCode"] = "ADD_COUNTRY_CODE";
      } else {
        arg["email"] = emailContoller.text;
      }

      arg["otp"] = otpContoller.text;

      await _otplessFlutterPlugin.verifyAuth(arg).then((value) {
        print("verifyAuth : $value");
      });
    } else {
      if (phoneNumberContoller.text.isNotEmpty) {
        arg["phone"] = phoneNumberContoller.text;
        arg["countryCode"] = "ADD_COUNTRY_CODE";

        await _otplessFlutterPlugin.initiatePhoneAuth(arg).then((value) {
          print("initiatePhoneAuth : $value");
        });
      } else if (emailContoller.text.isNotEmpty) {
        arg["email"] = emailContoller.text;

        await _otplessFlutterPlugin.initiateEmailAuth(arg).then((value) {
          print("initiateEmailAuth : $value");
        });
      } else {
        ScaffoldMessenger.of(context).showSnackBar(
          const SnackBar(
            content: Text("Please enter phone number or email"),
        ),
      );
    }
  }
}

Thank You #

Visit OTPless #

3
likes
0
points
64
downloads

Publisher

unverified uploader

Weekly Downloads

A versatile Flutter web package eliminating the need for OTP during user authentication. Simplify secure login workflows effortlessly.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on otpless_flutter_web