Junior — Middle
What is the main task of the FlowRow component and in what cases is it used?
sobes.tech AI
Answer from AI
FlowRow is a component in Jetpack Compose for Android that allows arranging child elements in rows with wrapping to the next line when there is not enough horizontal space.
The main task of FlowRow is to create adaptive, flowing layouts where elements automatically move to a new line if they do not fit in the current one.
FlowRow is used when:
- Displaying a set of elements, such as tags, buttons, or cards, that should automatically wrap.
- Making the interface flexible and adaptive to different screen sizes.
Example of usage:
FlowRow(
mainAxisSpacing = 8.dp,
crossAxisSpacing = 4.dp
) {
listOf("Android", "Kotlin", "Compose", "UI").forEach { tag ->
Chip(text = tag)
}
}
Thus, FlowRow simplifies the creation of multi-line horizontal lists with wrapping.