My code is given below the error I am facing issue in accessing the username from firebase in this line
snapshot.data['username']
It gives the error mentioned above
The only way I know to access the map data is this
FutureBuilder<Object>(
future: FirebaseFirestore.instance
.collection('users')
.doc(userId)
.get(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Text("Loading...");
}
return Text(
snapshot.data['username'],
style: TextStyle(
fontWeight: FontWeight.bold,
),
);
}
),