I\'m trying to convert documents to objects from Firestore, but when I create my data class , I dont know how to initialize the GeoPoint with default values as it needs to be de
The problem is that the Firestore SDK isn't finding a default, no argument constructor for MapObj. Kotlin data classes don't have one if all of their properties are declared with val
. For properties declared val
, Kotlin requires that their values be specified in the constructor, since they can't possibly change afterward.
If you must get a data class back from Firestore, you will have to make all of its properties optional var
with a default value, so that Kotlin will generate a no-arg constructor for it.
data class MapObj(var geopoint: Geopoint? = null)