flutter_auth_flow 0.1.0 copy "flutter_auth_flow: ^0.1.0" to clipboard
flutter_auth_flow: ^0.1.0 copied to clipboard

A single, fully customizable Flutter widget that handles Sign In, Sign Up, and Forgot Password — no routing, no multiple pages, just drop it in.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_auth_flow/flutter_auth_flow.dart';
import 'package:firebase_auth/firebase_auth.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const ExampleApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AuthFlow Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const AuthScreen(),
    );
  }
}

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

  @override
  State<AuthScreen> createState() => _AuthScreenState();
}

class _AuthScreenState extends State<AuthScreen> {
  void _navigateToHome() {
    Navigator.of(context).pushReplacement(
      MaterialPageRoute(builder: (_) => const HomeScreen()),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(24),
          child: Center(
            child: ConstrainedBox(
              constraints: const BoxConstraints(maxWidth: 420),
              child: AuthFlow(
                onSignIn: (email, password) async {
                  await FirebaseAuth.instance.signInWithEmailAndPassword(
                    email: email,
                    password: password,
                  );
                },
                onSignUp: (email, password, name) async {
                  final cred = await FirebaseAuth.instance
                      .createUserWithEmailAndPassword(
                    email: email,
                    password: password,
                  );
                  if (name.isNotEmpty) {
                    await cred.user?.updateDisplayName(name);
                  }
                },
                onForgotPassword: (email) async {
                  await FirebaseAuth.instance
                      .sendPasswordResetEmail(email: email);
                },
                onSignInSuccess: _navigateToHome,
                onSignUpSuccess: _navigateToHome,
                onForgotPasswordSuccess: () {
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(
                      content: Text('Password reset email sent!'),
                    ),
                  );
                },
              ),
            ),
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home'),
        actions: [
          IconButton(
            icon: const Icon(Icons.logout),
            onPressed: () => FirebaseAuth.instance.signOut(),
          ),
        ],
      ),
      body: const Center(
        child: Text('Welcome! You are signed in.'),
      ),
    );
  }
}
2
likes
150
points
55
downloads
screenshot

Documentation

API reference

Publisher

verified publisherpendura.in

Weekly Downloads

A single, fully customizable Flutter widget that handles Sign In, Sign Up, and Forgot Password — no routing, no multiple pages, just drop it in.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, firebase_auth, firebase_core, flutter, http

More

Packages that depend on flutter_auth_flow