import 'package:firebase_auth/firebase_auth.dart'; class AuthService { // instance of auth and firestore final FirebaseAuth _auth = FirebaseAuth.instance; // get current user User? getCurrentUser() { return _auth.currentUser; } /// sign in (login) /// /// @throws FirebaseAuthException Future signInWithEmailPassword(String email, password) async { try { UserCredential userCredential = await _auth.signInWithEmailAndPassword( email: email, password: password, ); return userCredential; } on FirebaseAuthException { rethrow; } } /// sign up (register) /// /// @throws FirebaseAuthException Future signUpWithEmailPassword(String email, password) async { try { // create user UserCredential userCredential = await _auth.createUserWithEmailAndPassword( email: email, password: password, ); return userCredential; } on FirebaseAuthException { rethrow; } } // sign out Future signOut() async { await _auth.signOut(); } }