firebase_auth_services 1.0.0 copy "firebase_auth_services: ^1.0.0" to clipboard
firebase_auth_services: ^1.0.0 copied to clipboard

In this application, you can use Firebase Authentication for user registration, login, email update, and logout functionalities, while managing the user token locally using Shared Preferences.

example/firebase_auth_services_example.dart

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth_services/firebase_auth_services.dart';

void main() async {
  
  await Firebase.initializeApp();

  
  AuthService authService = AuthService();

  
  String email = 'test@example.com';
  String password = 'password123';
  User? user = await authService.registerWithEmailAndPassword(email, password);
  if (user != null) {
    print('Registration successful: ${user.email}');
  } else {
    print('Registration failed');
  }

  
  user = await authService.loginWithEmailAndPassword(email, password);
  if (user != null) {
    print('Login successful: ${user.email}');
  } else {
    print('Login failed');
  }

  
  bool isLoggedIn = await authService.isLoggedIn();
  print('User is logged in: $isLoggedIn');

  
  bool emailUpdated = await authService.updateEmail('newemail@example.com');
  if (emailUpdated) {
    print('Email update successful');
  } else {
    print('Email update failed');
  }

  
  await authService.logout();
  print('User logged out');

  
  isLoggedIn = await authService.isLoggedIn();
  print('User is logged in: $isLoggedIn');
}
2
likes
120
points
36
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

In this application, you can use Firebase Authentication for user registration, login, email update, and logout functionalities, while managing the user token locally using Shared Preferences.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

firebase_auth, firebase_core, shared_preferences

More

Packages that depend on firebase_auth_services