You are declaring consentInformation
as a nullable field in line 14:
private var consentInformation: ConsentInformation? = null
As the field is mutable, its value could have changed between the execution of line 23 and line 24, so the compiler disallows you to refer to it without a null check.
In this specific case you could just change the field to be lateinit
as you're assigning it in the onCreate
method, which is executed first.
private lateinit var consentInformation: ConsentInformation
For more information about null safety in kotlin check this.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…