checkUserExists static method

Future<void> checkUserExists(
  1. User logInUser
)

Implementation

static Future<void> checkUserExists(User logInUser) async {
  late QuerySnapshot result;
  try {
    result = await FirebaseFirestore.instance
        .collection(getDocName())
        .where('userId', isEqualTo: logInUser.uid)
        .get();
  } catch (e) {
    print('ex ' + e.toString());
  }

  final List<DocumentSnapshot> documents = result.docs;
  if (documents.length == 0) {
    // Update data to server if new user
    await saveNewUser(logInUser);
  }
}