firebase_auth_services

Last updated:

0 purchases

firebase_auth_services Image
firebase_auth_services Images
Add to Cart

Description:

firebase auth services

AuthService Package #
A simple and efficient authentication service for Flutter applications using Firebase Authentication and Shared Preferences. This package provides functionalities for user registration, login, email update, and logout, while managing the user token locally.
Features #

Register with Email and Password
Login with Email and Password
Logout and clear user token
Update user email
Check if user is logged in
Retrieve current user

Installation #
Add the following to your pubspec.yaml file:
dependencies:
firebase_auth: ^4.1.0
shared_preferences: ^2.0.15
copied to clipboard
Then, run flutter pub get to install the dependencies.
Usage #
Import the package in your Dart file:
import 'auth_service.dart';
copied to clipboard
Register a New User #
AuthService authService = AuthService();

Future<void> registerUser() async {
User? user = await authService.registerWithEmailAndPassword(
'[email protected]',
'password123',
);
if (user != null) {
print('Registration successful!');
} else {
print('Registration failed.');
}
}
copied to clipboard
Login a User #
Future<void> loginUser() async {
User? user = await authService.loginWithEmailAndPassword(
'[email protected]',
'password123',
);
if (user != null) {
print('Login successful!');
} else {
print('Login failed.');
}
}
copied to clipboard
Logout a User #
Future<void> logoutUser() async {
await authService.logout();
print('User logged out.');
}
copied to clipboard
Update User Email #
Future<void> updateUserEmail() async {
bool success = await authService.updateEmail('[email protected]');
if (success) {
print('Email updated successfully!');
} else {
print('Email update failed.');
}
}
copied to clipboard
Check if User is Logged In #
Future<void> checkUserLoggedIn() async {
bool loggedIn = await authService.isLoggedIn();
if (loggedIn) {
print('User is logged in.');
} else {
print('User is not logged in.');
}
}
copied to clipboard
Get Current User #
User? user = authService.getCurrentUser();
if (user != null) {
print('Current user: ${user.email}');
} else {
print('No user is currently logged in.');
}
copied to clipboard
Contributing #
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License #
This project is licensed under the MIT License - see the LICENSE file for details.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.