title: How to also update user's name and image in comments sub-collection in Flutter via Firestore
body: <p>In my app, users can comment on every post and the comments are stored in the post's sub-collection: 'comments'. Each comments' document contains the poster's username, profile image, user Id, comment Id and some other fields.</p>
  <p>So I'm trying to also update each comments' document that contains a current user's userId when that user updates their profile.</p>
  <p>I have only been able to achieve the code below;</p>
  <pre><code>//Uploading the new image to storage
        final firebaseUser = FirebaseAuth.instance.currentUser!;
        final String uids = firebaseUser.uid;
        final Reference storageReference =
            FirebaseStorage.instance.ref().child(&quot;userImages- $uids&quot;);
        UploadTask uploadTask = storageReference.putFile(imageTemp);
        String downloadUrl = await (await uploadTask).ref.getDownloadURL();
  
        //Updating users' document with the new image
        final CollectionReference users =
            FirebaseFirestore.instance.collection(&quot;users&quot;);
        final String uid = firebaseUser.uid;
        String url = downloadUrl;
        await users.doc(uid).update({'url': url});
  
        //Trying to also update users' comments document with the image
  
        final CollectionReference posts =
            FirebaseFirestore.instance.collection(&quot;posts&quot;);
        await posts
            .doc()
            .collection('comments')
            .doc()
            .update({'profilePic': url});
  </code></pre>
  <p>How can I possibly achieve this? Any help will be appreciated.</p>