I am recording data coming from the user. I do need to get the document ID as soon as the document has been created. I have done some research and find this. But I am getting this error. Please, can you help me to fix this? Thank you.
CollectionReference users = FirebaseFirestore.instance
.collection('Users')
.doc(FirebaseAuth.instance.currentUser!.uid)
.collection('allTasks');
DocumentReference doc = await users
.add({
'task_Name' : _valueTaskNameSaved,
'project_Name': selectedProjectCapture,})
.then((value) => print("Task Created"))
.catchError((error) => print("Failed to add task: $error"));