Issue in flutter application while creating user in firebase db

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 :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<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;
}
}
</code>
<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; } } </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;
  }
}

New contributor

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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật