Flutter Map<String, dynamic>:从 Firestore 获取数据的问题

Flutter Map<String, dynamic>: Issues to get data from Firestore

我正在尝试从 Firestore 获取数据,但我在 Map 上遇到问题。知道如何解决这个问题吗?

    final QuerySnapshot result = await firestore.collection('markers').get();
    final List<DocumentSnapshot> documents = result.docs;
    int count = 0;
    documents.forEach((data) {
    Map<String, dynamic> datos = data.data;
      GeoPoint tmp = datos['position'];
      if (count < int.parse(data.id)) count = int.parse(data.id);
      final MarkerId markerId = MarkerId(data.id);
      LatLng point = LatLng(tmp.latitude, tmp.longitude);
      final Marker marker = Marker(
          markerId: markerId,
          position: point,
          infoWindow: InfoWindow(title: 'Id: ' + data.id),
          onTap: () {
            _onTapped(markerId);
          },
          icon: BitmapDescriptor.defaultMarkerWithHue(
              BitmapDescriptor.hueBlue));
      _markers[markerId] = marker;
    });
    _markerIdCounter = count + 1;
    setState(() {});
  }```
        final QuerySnapshot result = await firestore.collection('markers').get();
        final List<DocumentSnapshot> documents = result.docs;
        int count = 0;
        documents.forEach((data) {
// I changed this line
        Map<String, dynamic> datos = data.data() as Map<String, dynamic>;
          GeoPoint tmp = datos['position'];
          if (count < int.parse(data.id)) count = int.parse(data.id);
          final MarkerId markerId = MarkerId(data.id);
          LatLng point = LatLng(tmp.latitude, tmp.longitude);
          final Marker marker = Marker(
              markerId: markerId,
              position: point,
              infoWindow: InfoWindow(title: 'Id: ' + data.id),
              onTap: () {
                _onTapped(markerId);
              },
              icon: BitmapDescriptor.defaultMarkerWithHue(
                  BitmapDescriptor.hueBlue));
          _markers[markerId] = marker;
        });
        _markerIdCounter = count + 1;
        setState(() {});
      }`