从Firestore中提取数据时,我使用.toObject()
将接收到的数据映射到我的数据类中,即:
data class Img(var event_uid: String = "", var isVip: Boolean = false , var nombre: String = "", var url: String = "")
但是,映射做得并不好.我在任务中收到字段isVip=>true
,但对象字段被映射为False(默认值).
我做错了什么?
编辑:
W/Firestore: (0.6.6-dev) [zzevb]: No setter/field for isVip found on class ***.model.Img
根据Kotlin Docu:
If the name of the property starts with is, a different name mapping rule is used: the name of the getter will be the same as the property name, and the name of the setter will be obtained by replacing is with set. For example, for a property
isOpen
, the getter will be calledisOpen()
and the setter will be calledsetOpen()
. This rule applies for properties of any type, not justBoolean
.
Maybe a Firestore with Kotlin issue?