I am trying to retrieve an string url from FirebaseFirestore.
My code for UI is as follows
Container(
height: 65,
width: 65,
decoration: BoxDecoration(
border: Border.all(
width: 8,
color: const Color
.fromARGB(
255, 3, 54, 95)),
shape: BoxShape.circle,
color: Colors.black38),
child: ClipRRect(
borderRadius:
BorderRadius.circular(
22),
child: CachedNetworkImage(
imageUrl:
model.photoUrl,
fit: BoxFit.cover,
The code is trying to access a variable from the provider file, which is as follows:
photoUrl = AuthMethods().getPhotoUrl().toString();
//Authomethods file
Future<String> getPhotoUrl() async {
DocumentSnapshot snap = await FirebaseFirestore.instance
.collection('users')
.doc(FirebaseAuth.instance.currentUser!.uid)
.get();
final String photoUrl = (snap.data() as Map<String, dynamic>)['photoUrl'];
return photoUrl;
// return photoUrl;
}