Open Aatashh opened 3 years ago
somebody help!!!
use User instead of FirebaseUser
Thanks Nawab that is fixed now searching for _ChatScreenState
After firebase_auth version 0.18.0
Few breaking updates were made in firebase_auth 0.18.0. FirebaseUser is now called User, currentUser is a getter, and currentUser is synchronous.
This makes the code:
class _ChatScreenState extends State
@override void initState() { super.initState(); getcurrentuser(); }
void getcurrentuser() { try { final user = _auth.currentUser; if (user != null) { loggedInUser = user; print(loggedInUser.email); } } catch (e) { print(e); } }
Before firebase_auth version 0.18.0
email is a property of FirebaseUser object. Since auth.currentUser() return a future, you have to await in order to get the user object.
After firebase_auth version 0.18.0
Few breaking updates were made in firebase_auth 0.18.0. FirebaseUser is now called User, currentUser is a getter, and currentUser is synchronous.
This makes the code: class _ChatScreenState extends State { final _auth = FirebaseAuth.instance; User loggedInUser;
@override void initState() { super.initState(); getcurrentuser(); }
void getcurrentuser() { try { final user = _auth.currentUser; if (user != null) { loggedInUser = user; print(loggedInUser.email); } } catch (e) { print(e); } }
Before firebase_auth version 0.18.0
email is a property of FirebaseUser object. Since auth.currentUser() return a future, you have to await in order to get the user object.
Thank you Shivam!
After firebase_auth version 0.18.0
Few breaking updates were made in firebase_auth 0.18.0. FirebaseUser is now called User, currentUser is a getter, and currentUser is synchronous.
This makes the code: class _ChatScreenState extends State { final _auth = FirebaseAuth.instance; User loggedInUser;
@override void initState() { super.initState(); getcurrentuser(); }
void getcurrentuser() { try { final user = _auth.currentUser; if (user != null) { loggedInUser = user; print(loggedInUser.email); } } catch (e) { print(e); } }
Before firebase_auth version 0.18.0
email is a property of FirebaseUser object. Since auth.currentUser() return a future, you have to await in order to get the user object.
Thank you so much!!
In the exact same lesson, Please help while using modal progess hud so that it doesn't spin while the password and email are not entered and i click on login button but only spin when the user email and password are entered Roundbutton( title: 'Log In', onPressed: () async { setState(() { showSpinner= true; }); try{ final user = await _auth.signInWithEmailAndPassword(email: email, password: password); Navigator.pushNamed(context, ChatScreen.id); setState(() { showSpinner= false; }); } catch(e){ print(e); } }, ),
code is exactly matched with the lesson but these two errors came out of nowhere:-
lib/screens/chat_screen.dart:14:3: Error: Type 'FirebaseUser' not found. FirebaseUser loggedInUser; ^^^^^^^^^^^^ lib/screens/chat_screen.dart:12:7: Error: The non-abstract class '_ChatScreenState' is missing implementations for these members:
class _ChatScreenState extends State {
^^^^^^^^^^^^^^^^
/C:/flutter/packages/flutter/lib/src/widgets/framework.dart:1428:10: Context: 'State.build' is defined here.
Widget build(BuildContext context);
^^^^^
lib/screens/chat_screen.dart:14:3: Error: 'FirebaseUser' isn't a type.
FirebaseUser loggedInUser;
^^^^^^^^^^^^