Compose 1.13 moved FlexBox and Grid from experimental to stable, and the release notes say plainly that FlexBox supersedes FlowRow and FlowColumn for new code. Cue the pull requests titled "Remove Flow layouts."
Before you start a find-and-replace across the repository, it is worth being precise about what changed, what did not, and which failure modes are waiting on the other side of a mechanical migration. This post walks through the problem each container solves, compares FlexBox with the Flow layouts, covers the new maxItemsInEachLine option, builds a responsive dashboard on Grid, and ends with the cases where Flow still earns its place.
1. What problem each layout solves
Compose now has a crowded layout shelf. The fastest way to stop mixing them up is to start from the problem, not the name.
-
Row/Columnhandle content that already fits on one line. You split leftover space withweight, and that is about the end of the negotiation. -
FlexBox(andFlowRow/FlowColumnbefore it) handles one-dimensional content that may need to wrap. Items have a preferred size, and spare or missing space on each line is shared out by rules you control. -
Gridhandles two-dimensional structure: rows and columns that must line up, with spans and named areas. - Lazy lists and grids handle data you cannot afford to compose all at once.
The last point is the one teams forget. The official guidance for FlexBox is that it suits a small number of items inside a larger screen layout, and it does not compose lazily. Grid is likewise an eager container. Neither is a replacement for LazyVerticalGrid.
2. FlexBox vs FlowRow/FlowColumn, side by side
The short version: Flow layouts answer “wrap these when they run out of room.” FlexBox answers the same question and then lets each item take part in the negotiation through basis, grow, shrink, alignSelf and order.
A migration that compiles and still breaks
Here is a typical Flow usage: filter chips on a search screen. A small helper keeps the snippets focused (Filter is your own model type):
@Composable
private fun FilterOptionChip(filter: Filter, selected: Boolean, onToggle: () -> Unit) {
FilterChip(
selected = selected,
onClick = onToggle,
label = { Text(filter.label, maxLines = 1) },
)
}
// Before: FlowRow wraps by default.
FlowRow(
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
filters.forEach { filter ->
FilterOptionChip(filter, filter in active) { onToggle(filter) }
}
}
The naive translation is the trap:
// Looks right. Does not wrap.
FlexBox(config = { gap(8.dp) }) {
filters.forEach { filter ->
FilterOptionChip(filter, filter in active) { onToggle(filter) }
}
}
FlexBox defaults to FlexWrap.NoWrap. Items that do not fit stay on one line and overflow the container edge, partly clipped. On your 6.7-inch test device with four filters it looks fine. On a compact phone with a longer localized label, the last chip slides off-screen. The correct port makes the wrap explicit:
FlexBox(
config = {
wrap(FlexWrap.Wrap)
gap(8.dp)
}
) {
filters.forEach { filter ->
FilterOptionChip(filter, filter in active) { onToggle(filter) }
}
}
Two other differences are worth keeping in mind while you port:
-
Direction is configuration, not a different composable.
FlowColumnbecomesFlexBoxwithdirection(FlexDirection.Column). -
weightdoes not translate one-to-one. Flow layouts treatweightdifferently fromRow: the item's measured size acts as a minimum and it then expands into leftover space. InFlexBoxyou express that intent directly, withModifier.flex { basis(...); grow(1f) }. Decide what each weighted item was trying to do and write that, instead of renaming the modifier.
3. The new maxItemsInEachLine option
Flow layouts already had a per-line cap (maxItemsInEachRow on FlowRow, maxItemsInEachColumn on FlowColumn). Compose 1.13 adds the equivalent to FlexBox as a config option named maxItemsInEachLine, which limits how many items a line may hold when wrapping is on, no matter how much room is left.
Why does a cap matter if wrapping already adapts to width? Because fits and looks right are different questions. Consider six payment-method chips, each with a basis of 104 dp and grow = 1f, on a 600 dp wide window with 16 dp of horizontal padding. Five chips fit on the first line.
The sixth chip drops to its own line, and because it inherits grow, it stretches across the whole row. That is a real, shippable bug: it passes review on a phone, where three chips fit per line and everything is balanced, then looks wrong on a foldable or a tablet.
@Composable
fun PaymentMethodPicker(
methods: List<PaymentMethod>,
selected: PaymentMethod?,
onSelect: (PaymentMethod) -> Unit,
modifier: Modifier = Modifier,
) {
FlexBox(
modifier = modifier.fillMaxWidth(),
config = {
wrap(FlexWrap.Wrap)
gap(8.dp)
maxItemsInEachLine(3) // never more than three per line
},
) {
methods.forEach { method ->
FilterChip(
selected = method == selected,
onClick = { onSelect(method) },
label = { Text(method.label, maxLines = 1) },
modifier = Modifier.flex {
basis(104.dp)
grow(1f)
},
)
}
}
}
Two things to keep in mind:
-
The cap does not fix orphans by itself. Seven chips with a cap of three still produce a 3 + 3 + 1 layout. If your count is data-driven, decide whether a stretched last chip is acceptable. If it is not, give the chips a fixed
basisand dropgrow, so a lone chip stays chip-sized. - A cap is a maximum, not a promise. If the chips cannot fit three to a line at the current width, the line holds fewer. Test the extremes: largest font scale, narrowest window, and a long-label locale.
4. A responsive Grid example: an adaptive operations dashboard
Grid shines when the layout is a structure, not a stream: a handful of panels that must line up and that should rearrange as the window changes. The design below has four panels, shown at three widths.
The key feature is named areas. You register each area in the config block, then attach children with Modifier.gridItem(areaId = ...). Rearranging the layout means changing the config, not the children. Rows and columns in area(...) are 1-based.
GridConfigurationScope also exposes the constraints the Grid received from its parent, so the config block can choose tracks directly, with no BoxWithConstraints and no extra subcomposition.
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
// App-defined types and panels (stubs for this example):
// data class DashboardState(
// val summary: Summary, val trend: Trend,
// val alerts: List<Alert>, val activity: List<Event>,
// )
// @Composable fun SummaryPanel(summary: Summary, modifier: Modifier = Modifier)
// @Composable fun TrendPanel(trend: Trend, modifier: Modifier = Modifier)
// @Composable fun AlertsPanel(alerts: List<Alert>, modifier: Modifier = Modifier)
// @Composable fun ActivityPanel(events: List<Event>, modifier: Modifier = Modifier)
private enum class Panel { Summary, Trend, Alerts, Activity }
private enum class DashboardWidth { Compact, Medium, Expanded }
private fun widthClassFor(width: Dp) = when {
width < 600.dp -> DashboardWidth.Compact
width < 840.dp -> DashboardWidth.Medium
else -> DashboardWidth.Expanded
}
@Composable
fun OpsDashboard(
state: DashboardState,
modifier: Modifier = Modifier,
) {
Grid(
modifier = modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(16.dp),
config = {
gap(12.dp)
// `constraints` are the ones this Grid received from its parent;
// the config scope is also a Density, so toDp() resolves here.
when (widthClassFor(constraints.maxWidth.toDp())) {
DashboardWidth.Compact -> {
column(1.fr)
repeat(4) { row(GridTrackSize.Auto) }
area(areaId = Panel.Summary, row = 1, column = 1)
area(areaId = Panel.Trend, row = 2, column = 1)
area(areaId = Panel.Alerts, row = 3, column = 1)
area(areaId = Panel.Activity, row = 4, column = 1)
}
DashboardWidth.Medium -> {
repeat(2) { column(1.fr) }
repeat(3) { row(GridTrackSize.Auto) }
area(areaId = Panel.Summary, row = 1, column = 1, columnSpan = 2)
area(areaId = Panel.Trend, row = 2, column = 1, columnSpan = 2)
area(areaId = Panel.Alerts, row = 3, column = 1)
area(areaId = Panel.Activity, row = 3, column = 2)
}
DashboardWidth.Expanded -> {
repeat(3) { column(1.fr) }
repeat(3) { row(GridTrackSize.Auto) }
area(areaId = Panel.Summary, row = 1, column = 1, columnSpan = 3)
area(areaId = Panel.Trend, row = 2, column = 1, rowSpan = 2, columnSpan = 2)
area(areaId = Panel.Alerts, row = 2, column = 3)
area(areaId = Panel.Activity, row = 3, column = 3)
}
}
},
) {
SummaryPanel(state.summary, Modifier.gridItem(areaId = Panel.Summary))
TrendPanel(state.trend, Modifier.gridItem(areaId = Panel.Trend))
AlertsPanel(state.alerts, Modifier.gridItem(areaId = Panel.Alerts))
ActivityPanel(state.activity, Modifier.gridItem(areaId = Panel.Activity))
}
}
A few design choices here are deliberate:
-
Autorows inside a scroll container. The compact layout scrolls. Fractional (fr) and percentage tracks need a bounded height to divide, so under a vertical scroll I stick toAutorows. This is my own guidance from how those track types are defined, so confirm it against your layouts. -
The width class comes from the Grid’s own constraints. That is the space the dashboard is actually given, which is what a panel layout should react to. If a decision depends on the window instead (navigation chrome, for example), use window size classes or
mediaQueryat that level and pass the result down. - Children are width-agnostic. Each panel only knows its area name. Adding a fifth panel at one breakpoint is a config change plus one child.
Failure modes worth testing
A lazy list inside a flexible track can crash. Flexible tracks query their children for intrinsic sizes, and a LazyColumn cannot answer that question. Placing one in a standard fr track throws an IllegalStateException. The documented fix is to give the track an explicit minimum so the intrinsic pass is skipped:
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
// App-defined: data class Event(val id: Long, ...), @Composable fun EventRow(event: Event)
@Composable
fun RecentEventsPanel(events: List<Event>, modifier: Modifier = Modifier) {
Grid(
modifier = modifier.height(320.dp),
config = {
column(1f) // a percentage track: 100% of the width
row(GridTrackSize.Auto)
row(GridTrackSize.MinMax(0.dp, 1.fr)) // lets a LazyColumn live here
gap(8.dp)
},
) {
Text("Recent events")
LazyColumn {
items(events, key = { it.id }) { EventRow(it) }
}
}
}
Off-by-one in areas, and typos that fail silently. Grid lines and indices are 1-based, so a zero-based habit from list code shifts your layout by a cell. Separately, a gridItem(areaId = ...) whose ID was never registered in config does not crash: the item quietly falls back to automatic placement. Keep area IDs in an enum, as above, so a typo cannot compile.
Using Grid as a gallery. A photo gallery is the other half of the outline's suggestion, and it is a trap here. A gallery has an unbounded item count and wants virtualization, so the right tool remains LazyVerticalGrid with adaptive cells. Reach for Grid when the number of cells is small and known.
5. When to still use Flow layouts
“Superseded” is not “deleted.” The official guidance recommends FlexBox for new wrapping code. It does not tell you to rip out working Flow code. These are the situations where I would still reach for Flow:
-
You rely on
maxLines.FlowRowcan cap the number of lines and clip the rest. I found nomaxLinescounterpart in theFlexBoxreference, so treat that as "not documented," check your resolved version, and leave those call sites alone. Do not read this as a reason to adopt Flow's overflow-indicator APIs:FlowRowOverflow, theoverflowparameter, and the entireContextualFlowRowfamily are marked deprecated as no longer maintained. If you need a "+N more" chip, build it yourself by deciding how many items to show and rendering a trailing chip, in whichever container you use. -
You are pinned below Compose 1.13.
FlexBoxandGridare stable starting withfoundation-layout1.13.0. A module on an older BOM cannot adopt them yet, and in a multi-module build one lagging module can hold back the others. Do not fork your dependency graph for a chip row. -
The code is stable, tested, and not being touched. A migration is risk with no user-visible benefit unless you need
grow,shrink,basisororder. Port Flow call sites when you are already editing them. -
Plain wrapping, no negotiation. Tags or chips that all take their natural size are a clean fit for either container. For new code, pick
FlexBoxso the codebase converges on one wrapping container. For existing code, there is no emergency.
And the cases where I would not use Flow in new code: any time you want items to grow into spare space, shrink when squeezed, start from an explicit size, or render in an order different from composition order. That is FlexBox territory, and Flow cannot express it.
A practical migration checklist
- Replace the composable, then immediately set
wrap(FlexWrap.Wrap)where the old code relied on Flow's default wrapping. - Convert
horizontalArrangement/verticalArrangementspacing togap,rowGaporcolumnGap. - Rename
maxItemsInEachRowandmaxItemsInEachColumntomaxItemsInEachLine, and setdirectionfor column-oriented layouts. - Replace each
weightwith an explicitModifier.flex { basis(...); grow(...) }that states the intent. - Screenshot-test at the smallest window, the largest font scale, and your longest-label locale.
- Leave call sites that depend on
maxLineson Flow until you have confirmed an equivalent. Replace any use of deprecatedFlowRowOverflowwith a hand-built "+N" chip.
Takeaways
-
FlexBoxis the new default for wrapping one-dimensional content;Gridis for two-dimensional structure; neither is lazy. - The most common migration bug is forgetting that
FlexBoxdoes not wrap by default. -
maxItemsInEachLinecontrols line rhythm, but pair it with sensiblebasisandgrowso a short last line does not stretch. - Named areas make responsive
Gridlayouts a config problem instead of a composable-tree problem. - Flow still has a legitimate place for
maxLinesclipping and for modules that cannot move to 1.13 yet. Its overflow-indicator APIs are deprecated, so do not build on them.
References
- Android Developers Blog, What’s new in the Jetpack Compose November ’26 release: https://developer.android.com/blog/posts/jetpack-compose-november-2026-release
- Android Developers, FlexBox guides (overview, get started, container behavior): https://developer.android.com/develop/adaptive-apps/guides/flexbox
- Android Developers, Grid guides (get started, container properties): https://developer.android.com/develop/adaptive-apps/guides/grid/get-started
- Android Developers, Layout containers comparison: https://developer.android.com/develop/ui/compose/layouts/containers
- Android Developers API reference,
GridConfigurationScope,FlowRowOverflow,ContextualFlowRow: https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/GridConfigurationScope
📱 Crack Your Next Android Interview
If you’re targeting a senior Android role at a FAANG or top-tier MNC, syntax knowledge alone won’t get you through the loop. I highly recommend “Cracking Top MNC Android Interviews” — a senior-level playbook covering framework internals, Jetpack Compose, coroutines, Android-specific system design, and DSA reframed around real mobile constraints, to help you walk into bar-raiser rounds ready.
- E-book: Available on Google Play
- Kindle Edition: Available on Amazon
- Topmate: Available on Topmate
- Also available in Paperback & Hardcover.





Top comments (0)