Class

Immutable

[Immutable] can be used to mark class as producing immutable instances.

simpleImmutableClass

fun simpleImmutableClass() {
    @Immutable data class Person(val name: String, val phoneNumber: String)
    @Composable
    fun PersonView(person: Person) {
        Column {
            Row {
                Text("Name: ")
                Text(person.name)
            }
            Row {
                Text("Phone: ")
                Text(person.phoneNumber)
            }
        }
    }
    @Composable
    fun PeopleView(people: List<Person>) {
        Column {
            for (person in people) {
                PersonView(person)
            }
        }
    }
}