Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

183. Registering Users with Firebase using FirebaseAuth #36

Open
Aatashh opened this issue Feb 18, 2021 · 8 comments
Open

183. Registering Users with Firebase using FirebaseAuth #36

Aatashh opened this issue Feb 18, 2021 · 8 comments

Comments

@Aatashh
Copy link

Aatashh commented Feb 18, 2021

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:

  • State.build
    Try to either
  • provide an implementation,
  • inherit an implementation from a superclass or mixin,
  • mark the class as abstract, or
  • provide a 'noSuchMethod' implementation.

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;
^^^^^^^^^^^^

@Aatashh
Copy link
Author

Aatashh commented Feb 20, 2021

image

@Aatashh
Copy link
Author

Aatashh commented Feb 20, 2021

somebody help!!!

@ghost
Copy link

ghost commented Feb 20, 2021

use User instead of FirebaseUser

@Aatashh
Copy link
Author

Aatashh commented Feb 20, 2021

Thanks Nawab that is fixed now searching for _ChatScreenState

@shivamkg0604
Copy link

shivamkg0604 commented May 4, 2021

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.

@Aatashh
Copy link
Author

Aatashh commented Jun 1, 2021

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!

@sulavchhetri
Copy link

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!!

@sulavchhetri
Copy link

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);
}
},
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants