The getter 'uid' isn't defined for the type 'UserCredential'


I have been getting this error in futter while I was integrating firebase email,password sign up. "The getter uid isn’t defined for the type ‘UserCredential’." not only for uid but also for displayNmae and email. can anyone help me please?

void ValidateForm() async {
  FormState? formState = _formkey.currentState;
    Map value;
   if (formState!.validate()) {
       User user = await firebaseAuth.currentUser!;
   if (user == null) {
              email: _emailTextController.text,
              password: _passwordTextController.text)
          .then((user) => {
                    "username": user..displayName,
                    "userId": user.uid,
                    "gender": gender,
          .catchError((err) => {print(err.toDtring())});
          (context), MaterialPageRoute(builder: (context) => a_n()));


Your user value is a UserCredential object, to get the uid you need to access the user inside that.

  "userId": user.user.uid

Answered By – Huthaifa Muayyad

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.