I would like to use the isInitialized method on a lateinit property, but I can't because the compiler underlines in red with the error "Unresolved reference"
Here is the code :
class MainViewModel: ViewModel()
{
lateinit var myData: MutableLiveData<Data>
fun getData() {
if (this::myData.isInitialized)
}
}
I can't go any further because of that error...
Here is my gradle files :
project.gradle:
kotlin_version = '1.3.72'
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
app gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.core:core-ktx:1.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"