I managed to get apple sign in working and create a userdoc on my firestore collection ('Users). However when I log out and sign in again with apple it overwrites the name "" ... Because it only logs the name the first time you log in with apple. How do I stop the name field to be overwritten everytime the same person signs out and in again?

case AuthorizationStatus.authorized:
      try {
        final res = await FirebaseAuth.instance.signInWithCredential(credential);
        if (fixDisplayNameFromApple != null && res.user!.displayName == null) {
          await res.user!.updateDisplayName(fixDisplayNameFromApple);
          res.user!.reload();
        }
        FirebaseFirestore.instance.collection('Users').doc(res.user!.uid).set({
          'name' : fixDisplayNameFromApple,
          'email': res.user!.email,
          'uid': res.user!.uid,
          'image': 'https://merakiapp.be/wp-content/uploads/2022/06/appleUser.png',
        }, SetOptions(merge: true));
        return res.user;
      } catch (e) {
        print("error");
      }
      break;

I tried to check if the doc already exists so it doesn't create (overwrites) the original doc. But then it doesn't create a doc on firestore:

case AuthorizationStatus.authorized:
      try {
        final res = await FirebaseAuth.instance.signInWithCredential(credential);
        if (fixDisplayNameFromApple != null && res.user!.displayName == null) {
          await res.user!.updateDisplayName(fixDisplayNameFromApple);
          res.user!.reload();
        }
        await FirebaseFirestore.instance
            .collection("Users")
            .doc(res.user!.uid)
            .get()
            .then((doc) {
          if(doc.exists) {
            return res.user;
          } else {
            FirebaseFirestore.instance.collection('Users').doc(res.user!.uid).set({
              'name' : fixDisplayNameFromApple,
              'email': res.user!.email,
              'uid': res.user!.uid,
              'image': 'https://merakiapp.be/wp-content/uploads/2022/06/appleUser.png',
            }, SetOptions(merge: true));
            return res.user;
          }
        });
      } catch (e) {
        print("error");
      }
      break;