Firebase Firestore not creating collection at all

97 Views Asked by At

When users first sign up I want to store their sign-up data in a database. So I went with Firestore but now I have a problem. When users create their account that happens successfully the only problem their information not being stored. Even Firebase storage is not creating a storage bucket as it's supposed to. Here's how I wrote the sign up code:


CollectionReference get _users =>
      _firestore.collection(FirebaseConstants.usersCollection);

  FutureEither<UserModel> createAccount(
    String birthday,
    String email,
    String gender,
    String password,
    String username,
    Uint8List file,
  ) async {
    try {
      UserCredential credential = await _auth.createUserWithEmailAndPassword(
        email: email,
        password: password,
      );

      String profile = 'profile_pics';

      String avatarUrl = await _storageRepository.posttostorage(file, profile);

      UserModel userModel = UserModel(
        avatarUrl: avatarUrl,
        birthday: birthday,
        email: email,
        followers: [],
        following: [],
        gender: gender,
        password: password,
        username: username,
        userID: credential.user!.uid,
      );

      await _users.doc(credential.user!.uid).set(userModel.toMap());

      return right(userModel);
    } on FirebaseException catch (e) {
      throw e.message!;
    } catch (e) {
      return left(
        ErrorMessages(
          e.toString(),
        ),
      );
    }
  }

Please help me find what's wrong with my code. Thank you

0

There are 0 best solutions below