Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过使用颤振在设备半径内的位置显示Firebase firestore附近集合的集合_Firebase_Flutter_Google Maps_Google Cloud Firestore_Geolocation - Fatal编程技术网

如何通过使用颤振在设备半径内的位置显示Firebase firestore附近集合的集合

如何通过使用颤振在设备半径内的位置显示Firebase firestore附近集合的集合,firebase,flutter,google-maps,google-cloud-firestore,geolocation,Firebase,Flutter,Google Maps,Google Cloud Firestore,Geolocation,我正在开发一个应用程序使用颤振,像一个食品交付应用程序。所以我有餐厅应用程序和终端用户应用程序 我现在在做什么 Container( child: StreamBuilder( stream: nearbyComp(), builder: (context, snapshot) { if (!snapshot.hasData) { return Te

我正在开发一个应用程序使用颤振,像一个食品交付应用程序。所以我有餐厅应用程序和终端用户应用程序

我现在在做什么

Container(
            child: StreamBuilder(
              stream: nearbyComp(),
              builder: (context, snapshot) {
                if (!snapshot.hasData) {
                  return Text("Loading");
                }
                return Container(
                  child: Text("companyName"), // This needs to be changed to a list? Display company name, image, etc, here.
                );
              },
            ),
          ),
获取公司地址(地理位置),并将lat和lng与geohash一起使用,将位置存储在餐厅的Firestore集合中。对于终端用户应用程序,我将获取当前设备位置

我正在努力实现的目标

Stream nearbyComp() async* {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);
    final CollectionReference users =
        _firebaseFirestore.collection("Companies");

    double radius = 10;
    String field = 'location';

    Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: users)
        .within(center: point, radius: radius, field: field, strictMode: true);

    yield stream;
  }
在终端用户应用程序上,我想创建一个列表,如uber eats,使用终端用户设备的当前位置显示附近的餐厅,餐厅位置在我们的Firestore上

我正在使用GeoFlatterFireDependencie实现位置

我拥有的功能

Stream nearbyComp() async* {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);
    final CollectionReference users =
        _firebaseFirestore.collection("Companies");

    double radius = 10;
    String field = 'location';

    Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: users)
        .within(center: point, radius: radius, field: field, strictMode: true);

    yield stream;
  }
当前问题

Stream nearbyComp() async* {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);
    final CollectionReference users =
        _firebaseFirestore.collection("Companies");

    double radius = 10;
    String field = 'location';

    Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: users)
        .within(center: point, radius: radius, field: field, strictMode: true);

    yield stream;
  }
问题是,我找不到在最终用户屏幕上显示餐厅配置文件的方法,如图像、名称等。我想我需要一个ListView.Builder,但不知道如何使用nearComp()函数上的流来实现

我的Firestore

Stream nearbyComp() async* {
    var pos = await location.getLocation();

    GeoFirePoint point =
        geo.point(latitude: pos.latitude, longitude: pos.longitude);
    final CollectionReference users =
        _firebaseFirestore.collection("Companies");

    double radius = 10;
    String field = 'location';

    Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: users)
        .within(center: point, radius: radius, field: field, strictMode: true);

    yield stream;
  }


在您的streambuilder报表中:

return ListView(children: [
for (var item in snapshot.data) 
  ListTile( title: Text ( item["companyEmail"])) 
// Or use item.data()["companyEmail"], I didn't work with //geoFire, but these should work since it's firebase.
])

类型“\u AsBroadcastStream”不是类型“Iterable”的子类型,它返回的是:/and item.data()不起作用。嘿,你对可能出现的错误有什么看法吗?