flutter_2fa 1.0.4 copy "flutter_2fa: ^1.0.4" to clipboard
flutter_2fa: ^1.0.4 copied to clipboard

A flutter package to enable Two Factor Authentication in your app with an Authenticator.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: Scaffold(body: MyHome()));
  }
}

class MyHome extends StatelessWidget {
  const MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Padding(
          padding: const EdgeInsets.all(25),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              SizedBox(
                  width: double.infinity,
                  height: 56,
                  child: ElevatedButton(
                    onPressed: () => Flutter2FA().activate(
                        context: context,
                        appName: "Flutter 2FA",
                        email: "hipheckt@xyz.com"),
                    child: const Text('Activate 2FA'),
                  )),
              const SizedBox(height: 30),
              SizedBox(
                  width: double.infinity,
                  height: 56,
                  child: ElevatedButton(
                    onPressed: () => Flutter2FA()
                        .verify(context: context, page: const Success()),
                    style: ButtonStyle(
                      backgroundColor:
                          MaterialStateProperty.all<Color>(Colors.green),
                    ),
                    child: const Text('Login with 2FA'),
                  ))
            ],
          )),
    );
  }
}

class Success extends StatelessWidget {
  const Success({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(child: Text("user logged In Successfully!")),
    );
  }
}
6
likes
130
pub points
68%
popularity

Publisher

verified publisherifeoluwaafuwape.com

A flutter package to enable Two Factor Authentication in your app with an Authenticator.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bip39, flutter, otp, pinput, plugin_platform_interface, qr_flutter, shared_preferences

More

Packages that depend on flutter_2fa