Stream中“ future”的动态实例
其“未来”的返回实例 我想返回值字符串 我想返回值字符串
var channelName;
Future <String> _getrat(String id) async {
var x = await Firestore.instance.collection('users').document('$id').get();
print(x['name']);
return channelName = await x['name'];
}
Container(
child: Expanded(
child: StreamBuilder(
stream: Firestore.instance
.collection('ads')
.where('itemID', isEqualTo: itemid)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData == false) {
return Center(
child: Container(
new CircularProgressIndicator(
)));
} else {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (context, index) {
DocumentSnapshot mystore =
snapshot.data.documents[index];
Text('${_getrat(mystore['uid'])}'),