Last active
June 22, 2021 04:50
-
-
Save funwithflutter/27662393d7523b0adb68977d13d6d1ff to your computer and use it in GitHub Desktop.
Revisions
-
funwithflutter revised this gist
Sep 23, 2019 . No changes.There are no files selected for viewing
-
funwithflutter revised this gist
Sep 23, 2019 . 1 changed file with 58 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,67 @@ import 'package:firebase/firebase.dart'; import 'package:meta/meta.dart'; @immutable class UserRepository { UserRepository({Auth firebaseAuth, GoogleAuthProvider googleSignin}) : _firebaseAuth = firebaseAuth ?? auth(), _googleSignIn = googleSignin ?? GoogleAuthProvider(); final Auth _firebaseAuth; final GoogleAuthProvider _googleSignIn; Future<UserCredential> signInWithGoogle() async { try { return await _firebaseAuth.signInWithPopup(_googleSignIn); } catch (e) { print('Error in sign in with google: $e'); throw '$e'; } } Future<UserCredential> signInWithCredentials( String email, String password) async { try { return await _firebaseAuth.signInWithEmailAndPassword(email, password); } catch (e) { print('Error in sign in with credentials: $e'); // return e; throw '$e'; } } Future<UserCredential> signUp({String email, String password}) async { try { return await _firebaseAuth.createUserWithEmailAndPassword( email, password, ); } catch (e) { print('Error siging in with credentials: $e'); throw '$e'; // throw Error('Error signing up with credentials: $e'); // return e; } } Future<dynamic> signOut() async { try { return Future.wait([ _firebaseAuth.signOut(), ]); } catch (e) { print ('Error signin out: $e'); // return e; throw '$e'; } } Future<bool> isSignedIn() async { final currentUser = _firebaseAuth.currentUser; return currentUser != null; } Future<String> getUser() async { return (_firebaseAuth.currentUser).email; } } -
funwithflutter revised this gist
Sep 23, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ import 'package:firebase/firebase.dart'; Future<UserCredential> signInWithCredentials( String email, String password) async { try { -
funwithflutter created this gist
Sep 23, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ Future<UserCredential> signInWithCredentials( String email, String password) async { try { return await _firebaseAuth.signInWithEmailAndPassword(email, password); } catch (e) { print('Error in sign in with credentials: $e'); throw '$e'; } }