collectModulePreviews
Returns a Lazy that provides the list of @Preview functions collected from this module only.
The Compose Preview Lab compiler plugin replaces the Lazy initializer at compile time with the actual list of CollectedPreview instances. If the compiler plugin is not applied, accessing the value throws an IllegalStateException.
The return type is Lazy so that @Composable lambdas inside CollectedPreview are initialized on first access rather than at class-load time, avoiding ExceptionInInitializerError.
Example — single-module preview collection:
val myPreviews by collectModulePreviews()Content copied to clipboard
Example — used in a library module with public visibility:
// uiLib/src/commonMain/kotlin/Previews.kt
val uiLibPreviews by collectModulePreviews()Content copied to clipboard
Return
a Lazy wrapping the collected preview list; the initializer is replaced by the compiler plugin