soravparmar916 / flutter-authentication-

I create app with flutter using firebase. when i create authentication then it shows so much error in User class .I posted the Code. Please resolve my issue.
Apache License 2.0
0 stars 0 forks source link

Error during authentication . Errors are commenting in line #1

Open soravparmar916 opened 3 years ago

soravparmar916 commented 3 years ago

import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/cupertino.dart'; import 'package:google_sign_in/google_sign_in.dart';

class Authentication with ChangeNotifier { final FirebaseAuth firebaseAuth = FirebaseAuth.instance; final GoogleSignIn googleSignIn = GoogleSignIn();

String userUid; // error shows redline in userUid String get getUserUid => userUid;

Future<User?> logIntoAccount(String email, String password) async { UserCredential userCredential = await firebaseAuth .signInWithEmailAndPassword(email: email, password: password);

User user = userCredential.user;  // error shows redline in userCredential.user
userUid = user.uid;

print(userUid);
notifyListeners();

}

Future createAccount(String email, String password) async { UserCredential userCredential = await firebaseAuth .createUserWithEmailAndPassword(email: email, password: password);

User user = userCredential.user; // error shows redline in userCredential.user
userUid = user.uid;

print(userUid);
notifyListeners();

}

Future logOutViaEmail() async { return firebaseAuth.signOut(); }

Future signInWithGoogle() async { final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn(); // error showing on googleSignIn.signIn(); final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication;

final AuthCredential authCredential = GoogleAuthProvider.credential(
    accessToken: googleSignInAuthentication.idToken);

final UserCredential userCredential =
    await firebaseAuth.signInWithCredential(authCredential);

final User user = userCredential.user;  // error shows redline in userCredential.user

assert(user.uid != null);
userUid = user.uid;
print('Google User Uid => $userUid');
notifyListeners();

}

Future signOutWithGoogle() async { return googleSignIn.signOut(); } }

soravparmar916 commented 3 years ago

If anybody faces same issue please help me to resolve it. Thanks in advance

axijethwa74 commented 1 year ago

let me send your bug exception screenshot