add firebase to flutter
To add firebase to flutter watch this video
https://www.youtube.com/watch?v=EXp0gq9kGxI&feature=emb_title
add firebase to flutter
To add firebase to flutter watch this video
https://www.youtube.com/watch?v=EXp0gq9kGxI&feature=emb_title
flutter firebase google auth
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
class GoogleAuth {
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn();
User getUser() {
return _auth.currentUser;
}
Future<String> getUserId() async {
final User user = _auth.currentUser;
final uid = user.uid;
return uid;
}
Future<User> signInWithGoogle() async {
final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
final UserCredential authResult =
await _auth.signInWithCredential(credential);
final User user = authResult.user;
assert(!user.isAnonymous);
assert(await user.getIdToken() != null);
final User currentUser = _auth.currentUser;
assert(user.uid == currentUser.uid);
print('signInWithGoogle succeeded: $user');
return currentUser;
}
void signOutGoogle() async {
await googleSignIn.signOut();
print("User Sign Out");
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us