Flutter Firebase Firestore access a document with its document ID
Code:
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void demo() async {
String myDocId = 'user.uid';
DocumentSnapshot documentSnapshot;
await FirebaseFirestore.instance
.collection('Users') // suppose you have a collection named "Users"
.doc(myDocId)
.get()
.then((value) {
documentSnapshot = value; // you get the document here
});
//now you can access the document field value
var name = documentSnapshot['name'];
var location = documentSnapshot['location'];
}