@Composable fun MusicCategoriesScreen( categories: List<Category>, onCategorySelected:…
- User
@Composable fun MusicCategoriesScreen( categories: List, onCategorySelected: (Category) -> Unit = {}, modifier: Modifier = Modifier ) { LazyVerticalGrid( cells = GridCells.Fixed(2), contentPadding = PaddingValues(16.dp), modifier = modifier ) { items(categories) { category -> CategoryItem(category) { onCategorySelected(category) } } } } -> Cannot find a parameter with this name: cells:30,No value passed for parameter 'columns':33
- Assistant
You can't use LazyVerticalGrid since it is now deprecated in the Compose library. You'll need to use LazyVerticalGrid from the Accompanist library or use LazyColumn with a horizontal FlowRow inside it.
Here is an example of using LazyColumn and FlowRow:
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.example.Category // assuming your Category class is in this package @Composable fun MusicCategoriesScreen( categories: List<Category>, onCategorySelected: (Category) -> Unit = {}, modifier: Modifier = Modifier ) { val listState = rememberLazyListState() LazyColumn( state = listState, contentPadding = PaddingValues(16.dp), modifier = modifier ) { items(categories.chunked(2)) { row -> androidx.compose.foundation.layout.Row(modifier = Modifier.fillMaxWidth()) { row.forEach { category -> CategoryItem(category) { onCategorySelected(category) } } } } } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.