I am facing an issue in flutter application while creating user using firebase db. The user successfully created in authentication in firebase, but not in firestore.
This is the error i am encountered:
W/System ( 9991): Ignoring header X-Firebase-Locale because its value was null.
W/System ( 9991): Ignoring header X-Firebase-Locale because its value was null.
I/tergooglesigni( 9991): Background concurrent copying GC freed 63914(2787KB) AllocSpace objects, 9(308KB) LOS objects, 49% free, 3305KB/6611KB, paused 965us total 100.504ms
D/FirebaseAuth( 9991): Notifying id token listeners about user ( WsAb4Bc7dEgbw3FQdmsRQZbWMQZ2 ).
D/FirebaseAuth( 9991): Notifying auth state listeners about user ( WsAb4Bc7dEgbw3FQdmsRQZbWMQZ2 ).
I/flutter ( 9991): Error occurred: Error: type ‘List<Object?>’ is not a subtype of type ‘PigeonUserDetails?’ in type cast
I/flutter ( 9991): <<<———————————————–: Error: type ‘List<Object?>’ is not a subtype of type ‘PigeonUserDetails?’ in type cast———————————————>>>
F/crash_dump32(13059): crash_dump.cpp:474] failed to attach to thread 180: Permission denied
I/tergooglesigni( 9991): Thread[6,tid=10003,WaitingInMainSignalCatcherLoop,Thread*=0x9b400e10,peer=0xa06401e8,”Signal Catcher”]: reacting to signal 3
I/tergooglesigni( 9991):
I/libc ( 9991): Requested dump for tid 9991 (tergooglesignin)
I/tergooglesigni( 9991): Wrote stack traces to tombstoned
This is my authentication.dart code :
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
class AuthServices {
final FirebaseFirestore _firestore = FirebaseFirestore.instance;
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
Future<String> signupUser({
required String name,
required String email,
required String password,
}) async {
if (name.isEmpty || email.isEmpty || password.isEmpty) {
return "Error: Invalid input parameters";
}
String res = "An error occurred"; // Default error message
try {
// Create a new user with email and password
UserCredential userCredential = await _firebaseAuth
.createUserWithEmailAndPassword(email: email, password: password);
if (userCredential.user != null) {
String uid = userCredential.user!.uid;
print("User ID: $uid");
// Add user details to Firestore under 'users' collection
await _firestore.collection("users").doc(uid).set({
'name': name,
'email': email,
'uid': uid,
});
print("Successfully added to Firestore");
res = "Successfully executed";
} else {
res = "User creation failed: user is null";
print("Error: User creation failed");
}
} catch (e) {
// Log detailed error message
res = "Error: ${e.toString()}";
print("Error occurred: $res");
}
print("<<<-----------------------------------------------: $res--------------------------------------------->>>");
return res;
}
}
Vamsi Krishna Peruri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.