Annotates that a class should not be retained (i.e. used in the return type of the calculation lambda given to the retain {} method in androidx.compose.runtime).

When present on a class, a lint error will be reported when the class or any of its subclasses appear as the generic type of a call to retain. The associated inspection only checks the direct return type of the calculation lambda, but retained values should hold no strong references, direct or indirect, to any type marked as DoNotRetain.

Generally, this annotation is expected to be used on resources that will be leaked if they are retained. Additional or other rationale may be provided by specifying an explanation, which will appear in the lint error message when applicable.

Summary

Public constructors

DoNotRetain(explanation: String)
Cmn

Public properties

String

An optional explanation of why this class should not be retained.

Cmn

Public constructors

DoNotRetain

DoNotRetain(explanation: String = "")

Public properties

explanation

val explanationString

An optional explanation of why this class should not be retained. If this value is not an empty string, it will be presented in the error description at the callsite of offending usages of this type.