Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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
Flutter “处理”;Flatter firestore中的DocumentSnapshotPlatform中不存在错误状态字段_Flutter_Google Cloud Firestore - Fatal编程技术网

Flutter “处理”;Flatter firestore中的DocumentSnapshotPlatform中不存在错误状态字段

Flutter “处理”;Flatter firestore中的DocumentSnapshotPlatform中不存在错误状态字段,flutter,google-cloud-firestore,Flutter,Google Cloud Firestore,我在应用程序中添加了一个新文档/字段,用于检查用户何时再次联机。 当然,当用户重新联机时,这些新字段将由用户创建,但在我检查此异常的地方,我试图设置一个例外,例如: widget.snapshot['lastAccess'] == null ? Container():The RightWidget 问题是这个字段不是空的,它不存在,直到用户再次登录到应用程序,并且这个字段将被创建,但是直到这个时候,如果这个字段不存在,我需要放置一个异常。 我还尝试了widget.snapshot['last

我在应用程序中添加了一个新文档/字段,用于检查用户何时再次联机。 当然,当用户重新联机时,这些新字段将由用户创建,但在我检查此异常的地方,我试图设置一个例外,例如:

widget.snapshot['lastAccess'] == null ? Container():The RightWidget
问题是这个字段不是空的,它不存在,直到用户再次登录到应用程序,并且这个字段将被创建,但是直到这个时候,如果这个字段不存在,我需要放置一个异常。 我还尝试了
widget.snapshot['lastAccess']不可用',
但当然,此方法还会检查字段是否为空。。。
如果字段不存在,我需要捕获异常…

检查
containsKey
方法,如下所示

if(snapshot.data().containsKey("lastAccess")){

}
else{

}

你不能将字段初始化为空吗?问题是我需要在Firestore中将一个新文档添加到集合中为空,但我的问题是,是否可以处理不存在的文档而不是空的文档?你的意思是不存在的字段吗?是的,不存在的字段