turbo_fireauth 0.0.2
turbo_fireauth: ^0.0.2 copied to clipboard
A lightweight Firebase Authentication wrapper for Flutter. Simplify auth logic with a clean API supporting Email, Google, Apple, Facebook, X (Twitter), and Yahoo Sign-In.
TurboFireAuth 🚀 #
A Flutter package for easy and clean Firebase Authentication.
Simplify your auth logic with a clean, singleton-based approach supporting Email/Password and Google Sign-In out of the box.
Note: If your project is initialized with the FlutterFire CLI, providing
FirebaseOptionsto theinitializemethod is not required, as it will be handled by the system's default configuration.
Features ✨ #
- Clean Singleton API: Access everything via
TurboFireAuth.instance. - Multiple Auth Providers: Supports Email/Password (Login & Register), Facebook, X(Twitter), Yahoo and Google Sign-In.
- Comprehensive Results: Instead of catching exceptions, handle specific
LoginResulttypes. - User Management: Easy methods for password reset, profile updates, and current user retrieval.
- Ready for Web & Mobile: Handles persistence and platform-specific logic internally.
Installation 📦 #
Add turbo_fireauth to your pubspec.yaml:
dependencies:
turbo_fireauth: ^0.0.2
Then run:
flutter pub get
Usage 🛠️ #
1. Initialization #
Initialize the package in your main.dart before calling any auth methods.
import 'package:turbo_fireauth/turbo_fireauth.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await TurboFireAuth.instance.initialize(
// Optional: provide FirebaseOptions for manual initialization
// If using FlutterFire CLI, this is handled automatically.
// options: DefaultFirebaseOptions.currentPlatform,
googleSigninConfig: GoogleSigninConfig(
clientId: "YOUR_GOOGLE_CLIENT_ID",
),
);
runApp(MyApp());
}
2. Login / Register #
Email Login
final result = await TurboFireAuth.instance.login(
EmailLogin("user@example.com", "password123"),
);
if (result is Success) {
print("Welcome ${result.user.email}!");
} else if (result is WrongPasswordFailure) {
print("Oops, wrong password.");
}
Google Sign-In
final result = await TurboFireAuth.instance.login(GoogleLogin());
3. User Actions #
// Logout
await TurboFireAuth.instance.logout();
// Get Current User
final user = await TurboFireAuth.instance.getCurrentUser();
// Reset Password
await TurboFireAuth.instance.sendPasswordResetEmail("user@example.com");
// Update Profile
await TurboFireAuth.instance.updateUserName("New Name");
Handling Results 🎯 #
TurboFireAuth returns a LoginResult for all login operations, making error handling predictable:
Success: Login successful, contains theUser.EmailAlreadyExistsFailure: Registration failed because email is in use.WrongCredentials: Invalid email or password.UserDisabledFailure: The user account has been disabled.LoginCancelledFailure: User closed the login popup/modal.- And many more...
Contribution 🤝 #
Feel free to open issues or submit pull requests to help improve this package!
License 📄 #
This project is licensed under the Apache License 2.0.