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

Plug-and-play Firebase Email/Password authentication for Flutter. Get Login, Register, Forgot Password screens and an AuthGate widget working in under 5 minutes — fully themeable, zero boilerplate.

hack_auth 🔐 #

pub.flutter-io.cn License: MIT

Plug-and-play Firebase authentication for Flutter hackathons.
Install → configure → ship. Done in under 5 minutes.


✨ Features #

Feature Included
Email / Password Login
Registration (with display name)
Forgot Password (email link)
Logout
AuthGate (auto-routing)
Friendly Firebase error messages
Dark-mode UI out of the box
Fully customisable theme

🚀 Quick Start #

1. Add to pubspec.yaml #

dependencies:
  hack_auth: ^0.1.0

2. Enable Firebase #

This package requires a Firebase project with Email/Password authentication enabled.

The easiest way to configure Firebase is with the FlutterFire CLI:

dart pub global activate flutterfire_cli
flutterfire configure

Or pass FirebaseOptions manually (see Step 3).

3. Initialize #

import 'package:hack_auth/hack_auth.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await HackAuth.initialize(
    firebaseOptions: FirebaseOptions(
      apiKey: 'YOUR_API_KEY',
      appId: 'YOUR_APP_ID',
      messagingSenderId: 'YOUR_MESSAGING_SENDER_ID',
      projectId: 'YOUR_PROJECT_ID',
    ),
    theme: HackAuthTheme(primaryColor: Colors.indigo), // optional
  );

  runApp(MyApp());
}

4. Add AuthGate #

MaterialApp(
  home: AuthGate(
    authenticated: HomePage(),
    unauthenticated: LoginPage(),
  ),
);

That's it. 🎉 Your app now has a working login, registration, and forgot-password flow.


📱 Screens #

LoginPage #

LoginPage(
  title: 'Welcome Back',          // optional
  loginButtonText: 'Sign In',     // optional
  theme: HackAuthTheme(...),       // optional
  onLoginSuccess: () {
    // called after successful login
    // if using AuthGate, you don't need this
  },
)

RegisterPage #

RegisterPage(
  title: 'Create Account',
  registerButtonText: 'Sign Up',
  onRegisterSuccess: () { ... },
)

ForgotPasswordPage #

ForgotPasswordPage(
  title: 'Reset Password',
  onEmailSent: () { ... },
)

🎨 Theming #

HackAuthTheme(
  primaryColor: Color(0xFF6C63FF),
  backgroundColor: Color(0xFF0F0F1A),
  surfaceColor: Color(0xFF1C1C2E),
  textColor: Color(0xFFEFEFEF),
  hintColor: Color(0xFF8A8A9A),
  errorColor: Color(0xFFFF5C5C),
  borderRadius: 14,
  logo: AssetImage('assets/logo.png'),  // shown on all screens
  logoHeight: 80,
)

🔒 Direct API Usage #

// Login
await HackAuth.login(email: email, password: password);

// Register
await HackAuth.register(email: email, password: password);

// Logout
await HackAuth.logout();

// Reset password
await HackAuth.resetPassword(email: email);

// Current user
final user = HackAuth.currentUser;
print(user?.email);

// Auth state stream
HackAuth.authStateChanges.listen((user) { ... });

All methods throw HackAuthException on failure:

try {
  await HackAuth.login(email: email, password: password);
} on HackAuthException catch (e) {
  print(e.message); // "No account found with this email."
}

🗂️ Package Architecture #

hack_auth/
├── lib/
│   ├── hack_auth.dart          ← Public API barrel
│   └── src/
│       ├── hack_auth_main.dart ← HackAuth static facade
│       ├── config/
│       │   └── hack_auth_theme.dart
│       ├── models/
│       │   ├── auth_result.dart
│       │   └── auth_exception.dart
│       ├── services/
│       │   └── auth_service.dart
│       ├── screens/
│       │   ├── login_page.dart
│       │   ├── register_page.dart
│       │   └── forgot_password_page.dart
│       └── widgets/
│           ├── auth_button.dart
│           ├── auth_text_field.dart
│           └── auth_gate.dart
└── example/
    └── lib/main.dart

📄 License #

MIT © 2024 — (https://github.com/Atharva660)

0
likes
140
points
79
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Plug-and-play Firebase Email/Password authentication for Flutter. Get Login, Register, Forgot Password screens and an AuthGate widget working in under 5 minutes — fully themeable, zero boilerplate.

Repository (GitHub)
View/report issues

Topics

#firebase #authentication #login

License

MIT (license)

Dependencies

firebase_auth, firebase_core, flutter

More

Packages that depend on hack_auth