firebase - 我在 Firestore 中有数据,并提交了值,但其中一些显示为 null
问题描述
我在firestore中有一个集合,我正在将数据从firestore获取到我的应用程序,并将纬度和经度转换为地址,它可以与其他文档一起使用,但是其中一个文档向我显示该字段为空的错误,但它有一个值,如你所见
我在 Firestore 中总是遇到这个问题,所以有时我删除了文档并重新创建了它,但是每次都这样做很累,我的 Firestore 有什么问题?谁能帮我这个?
这是转换纬度和经度的方法
Future<String> gymLocation ;
@override
void initState() {
gymLocation = translate.getAddressFromLatLng(widget.gym.gym_region_lat_long.latitude,widget.gym.gym_region_lat_long.longitude);
Future<String> getAddressFromLatLng(double lat , double long) async {
String stringAddress='';
try {
List<Placemark> p = await geolocator.placemarkFromCoordinates(lat,
long);
final coordinates = new Coordinates(lat, long);
var address = await
Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = address.first;
Placemark place = p[0];
final cor2 = await Geocoder.local.findAddressesFromQuery(place.name);
var ad2 = cor2.first;
stringAddress = first.addressLine;
print(stringAddress +' current address');
print('${first.featureName} ,\n${first.addressLine}');
print('${ad2.coordinates}');
// return string_address;
} catch (e) {
print(e);
}
return stringAddress;
}
这是在文本小部件中显示地址的方法
gymAddressContainter(gym_model gym) {
return FutureBuilder<String>(
future: gymLocation,
builder:(context, snapshot)
{
if (snapshot.hasError) {
return Center(child: Text('No data'));
}
else if (snapshot.hasData) {
return Container(
padding: EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
adressText(
widget.gym.gym_address['g_phone'].toString(), Icons.phone,
Colors.green),
adressText(widget.gym.gym_address['g_email'], Icons.email,
Colors.amber),
adressText(widget.gym.gym_address['g_website'], Icons.public,
Colors.blue),
adressText(snapshot.data, Icons.location_on, Colors.pink)
],
)
);
}
else return Center(child:CircularProgressIndicator());
}
);
}
这就是我将文档从 firrestore 映射到 dart 的方式
gym_model.map(dynamic obj){
this.gym_name = obj['gym_name'];
this.gym_region = obj['gym_region'];
this.gphoto= obj['gphoto'];
this.gym_region_lat_long = obj['gym_region_lat_long'];
this.gym_city_point = obj['gym_city_point'];
this.gym_address['g_email']= obj['gym_address']['g_email'];
this.gym_address['g_phone'] =obj['gym_address']['g_phone'];
this.gym_address['g_website'] = obj['gym_address']['g_website'];
其他文件工作正常,但仅适用于这个健身房 Rashad 体育俱乐部,它具有价值..
在 Firestore 中总是有问题,当我创建一个集合并创建文档并为每个文档放置值时,一些文档显示为 null,并给我这个消息错误
PlatformException(失败,失败,空)
解决方案
推荐阅读
- javascript - 创建刮刮卡但容器不会在最后显示
- regex - 如何在perl中匹配以-----BEGIN PRIVATE KEY-----开头的键?
- javascript - 使用带有 Node.js 的 Google Sheets API 从 Google Sheets 导出数据
- c++ - 如何将循环中的信息存储到数组中
- django - 如何在 Django 中间件中忽略媒体和静态 URL
- angular - 我正在使用 angular 6.1.0 angular-cli 7 primeng 7:出现错误,因为“环境上下文中不允许使用初始化程序”
- geotools - GeoTools 中是否有一些用于从栅格数据转换为矢量数据的 API?
- linear-algebra - 从旋转矩阵分解音高(y轴旋转)时的歧义
- linux - 发生了什么我的 ttyS0 在 /proc/interrupt 中没有 irq 列表
- corda - 执行 ContractUpgradeFlow 后状态合同不会改变