流中“ future” <string>的抖动实例

时间:2019-05-13 03:35:38

标签: dart flutter google-cloud-firestore

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'])}'),

0 个答案:

没有答案