从Firebase Firestore数据库集合中提取大量(大约300个)文档

时间:2020-02-26 10:36:06

标签: firebase flutter dart google-cloud-firestore

我正在尝试从Firestore获取数据。该代码在FutureBuilder ListView中正常工作。我尝试将所有条目打印到控制台。下面的代码工作正常,但仅打印前10个左右的条目。

Future getP() async {
  var firestore = Firestore.instance;
  var q = await firestore.collection('place_list').getDocuments();
  List<Map<String, dynamic>> list = q.documents.map((DocumentSnapshot doc) {
    return doc.data;
  }).toList();
  print(list);
  return q.documents;
}

The code :

The console output :

我想将所有300个条目打印在控制台中。有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

尝试使用此 debugPrint 代替 print

debugPrint(list.toString(), wrapWidth: 1024);

或添加此方法和

void printWrapped(String text) {
  final pattern = new RegExp('.{1,800}'); // 800 is the size of each chunk
  pattern.allMatches(text).forEach((match) => print(match.group(0)));
}

致电

printWrapped(list.toString());

检查this以获得更多信息。

相关问题