无法从Firestore读取数据

时间:2020-01-19 13:29:14

标签: firebase flutter dart google-cloud-firestore

我试图使用json读取Firestore中的数据,而Map类型必须实现可迭代

Stream<List<RentModel>> readData(){
    var json = collection.document("rent").snapshots();
    List<RentModel> rentModel = List();
    return json.map((document) {
      for (var index in document.data){     // error is here in document.data that: the type Map<String, dynamic> must implements iterable 
        rentModel.add(RentModel.fromJson(index));
      }
      return rentModel;
    });
  }

0 个答案:

没有答案