I am writing a social Media app where the user can post and read post from other users. My problem is here, I want an updated name from the user who wrote a post so that the latest name, when the user updates it's name, should appear on the post.
In this code of mine I am getting the error
The argument type 'Future<String?>' can't be assigned to the parameter type 'String'
Widget postList (){
return Container(
child: StreamBuilder(
stream: some Stream
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot){
return !snapshot.hasData ?
CircularProgressIndicator():
ListView(
children: snapshot.data!.docs.map((document) {
return InkResponse(
child: Container(
child: Column(
children: <Widget>[
Row(
children: [
// I'm having trouble here
/** What I want to happen is to retrieve the NAME of the user using UID so that even if the
Writer changes his name, the latest name shall appear on this */
Text ( getWriterInformation(uid: document['poster_uid']),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16)),
],
),
],
),
),
);
}).toList(),
);
},
);
}
Future <String?> getWriterInformation ({required String uid}) async {
await Users.doc(uid).get().then((value){
return value['display_name'].cast<String>();
});
}
}
If you can recommend any other way aside from my way to do this, I will gladly to appreciate it.