大佬教程收集整理的这篇文章主要介绍了如何使用 Firebase firestore 集合上的流使用 Flutter 按设备半径内的位置显示附近的集合,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Flutter 开发应用程序,例如送餐应用程序。所以我有餐厅应用和最终用户应用。
我现在在做什么
获取公司地址 (geoLOCATIOn),并使用 lat 和 lng 和 geohash 将位置存储在 Firestore 集合中的餐厅。对于最终用户应用程序,我正在获取当前设备位置。
我想要达到的目标
在最终用户应用上,我想创建一个列表,例如 ubereats,使用最终用户设备的当前位置以及 Firestore 上的餐厅位置来显示附近的餐馆。
我正在使用 GeoFlutterFire 依赖项来获取位置。
我拥有的功能
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;
}
我想在哪里显示列表
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.
);
},),
当前问题
问题是,我找不到在最终用户屏幕上显示餐厅资料的方法,例如图像、名称等。我想我需要一个 ListVIEw.builder,但不知道该怎么做它与 NearComp() 函数上的 Stream 一起使用。
我尝试过的:
return ListVIEw(children: [
for (var item in snapshot.data)
ListTile( title: Text ( item["companyEmail"]))
// Or use item.data()["companyEmail"]
])
但它返回给我这个错误:
type '_AsbroadcastStream<List<documentSnapshot>>' is not a subtype of type 'Iterable<dynamic>'
我的 Firestore
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如何使用 Firebase firestore 集合上的流使用 Flutter 按设备半径内的位置显示附近的集合全部内容,希望文章能够帮你解决如何使用 Firebase firestore 集合上的流使用 Flutter 按设备半径内的位置显示附近的集合所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。