Populating a LazyColumn composable
So, we added a LazyColumn composable to our screen. For us to benefit from the LazyColumn composable, we need to add content to it. Let’s see how we go about doing that.
As we mentioned before, to add content to our LazyColumn composable, we would need to populate its LazyListScope-extending block. In this block, we tell the LazyColumn composable how to plug data into composables designed to present that data.
For example, let’s say we want to present a list of employees. Here are the steps that we’ll take:
- We need to design our UI model. This will be a data class holding all the information our app needs for it to present a single employee. Because this is a UI model, one convention is to suffix its name with
UiModel:data class EmployeeUiModel( val name: String, val role: EmployeeRole, val gender: Gender, val imageUrl: String...