but compose metrics reports it as unstable. Am I doing something wrong here? I think this only started happening when I refactored the class to a shared package
vide
01/02/2023, 9:16 AM
Copy code
package app.shared
@Immutable
data class MyImmutableClass(val foo: Foo)
Copy code
package app.main
@Composable
fun MyComposable(param: MyImmutableClass) {...}
Results in the following metrics:
Copy code
restartable fun MyComposable(
unstable param: MyImmutableClass
)
vide
01/02/2023, 9:33 AM
Resolved! I had to add androidx.compose.foundation to the shared package and import
androidx.compose.runtime.Immutable
instead of
javax.annotation.concurrent.Immutable
which Android Studio recommends first 😄
s
sindrenm
01/02/2023, 10:57 AM
In case you weren't aware, you can make sure it won't suggest
javax.annotation.concurrent.Immutable
by putting it the list found at Settings → Editor → General → Auto Import → Exclude from auto-import […]. I've found this very useful for Compose. simple smile