otpless_flutter_web 1.1.5 otpless_flutter_web: ^1.1.5 copied to clipboard
A versatile Flutter web package eliminating the need for OTP during user authentication. Simplify secure login workflows effortlessly.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:otpless_flutter_web/otpless_flutter_web.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Otpless Flutter Web Testing',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
String? name;
String? number;
//Define the instance
final _otplessFlutterPlugin = Otpless();
//************************************************************************* */
//This function will run the floater in the app which contains the WhatsApp button for Authentication
//************************************************************************* */
void startHeadless(String channelType) async {
await _otplessFlutterPlugin.startHeadless(channelType).then((value) {
log(value);
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
onPressed: () {
startHeadless("WHATSAPP");
},
child: const Text(
"Login",
),
),
body: Center(
child: Column(
children: [
Text(
"Name : $name",
style: const TextStyle(
fontSize: 25,
),
),
const SizedBox(height: 10),
Text(
"Number : $number",
style: const TextStyle(
fontSize: 25,
),
),
],
),
),
);
}
}