New to Rust? Grab our free Rust for Beginners eBook Get it free →
Flutter Horizontal List: Create a Scrolling Row

When items on a Flutter screen extend beyond the available width, a sideways-scrolling row lets you reach them. A horizontal ListView lays out widgets in a row and lets the row scroll sideways.
I’ll show how to set the row’s height and choose between writing a short set of widgets directly or building items from data.
TL;DR
Set a ListView’s scrollDirection to Axis.horizontal and place it in a parent that gives it a finite height.
- Use ListView(children: …) for a short, fixed row.
- Use ListView.builder for data-backed items created on demand.
- Use ListView.separated when the row needs a spacer or divider between items.
What is a horizontal ListView in Flutter?
A ListView is a scrollable viewport that lays out child widgets in sequence.
The viewport reveals only the portion of its children that fits on screen. Its construction API lets the row use prebuilt widgets or callbacks.
With Axis.horizontal, items follow the main axis. The cross axis runs vertically, so the parent must set the row height. This is the reason the outer SizedBox in the example has a height.
Flutter passes layout constraints from parent to child. A Column may need Expanded when the row should fill remaining space, or SizedBox when it should keep a chosen height. Choose based on how the row fits the rest of the screen.
A fixed row can hold labels, images or custom widgets. For data-backed rows, each value can produce one card. Give each card a deliberate width so the next item’s position stays predictable.
How to create a horizontal list in Flutter step by step
A horizontal ListView combines a data source with a viewport that moves along the row, with item dimensions set by each child or builder.
Step 1: Prepare a Flutter screen and item data
Put the list in a Scaffold body or another bounded region. Keep data separate from its visual widget when the row is generated from values.
A nested Column can change the constraints passed to a child. When an exception names an unbounded dimension, inspect the immediate parent before changing the list constructor.
final List<String> categories = <String>[
'Books',
'Music',
'Games',
'Travel',
];
The viewport is the visible window onto the row, so a horizontal list suits cards or categories that extend beyond it. A tab control is better when selecting a label must coordinate page content.
This list holds labels rather than prebuilt widgets. Its length is available through categories.length.
Step 2: Give the horizontal viewport a height
A SizedBox makes the row’s vertical extent explicit.
SizedBox(
height: 120,
child: ListView(
scrollDirection: Axis.horizontal,
children: const <Widget>[
SizedBox(width: 160, child: Card(child: Center(child: Text('Books')))),
SizedBox(width: 160, child: Card(child: Center(child: Text('Music')))),
],
),
)
Each inner SizedBox sets a card’s width. Choose a height that leaves room for the card content and padding.
The inner width determines how much horizontal space a card occupies. The outer height sets the viewport available to the row.
Setting one dimension does not replace the other. If a card uses a Row internally, constrain that content so its children do not compete for unbounded width.
The outer SizedBox bounds the viewport, not the full content row. If the cards extend beyond the available screen width, ListView can scroll to reveal them while keeping its visible height fixed. This separation lets a card be wider than the remaining screen space.
Keep the dimensions intentional. A very short viewport can clip text or controls, while a tall viewport may consume space needed by the rest of the page. When card content has variable height, choose the row height for the tallest expected card and check that text wrapping does not conceal important actions.
Step 3: Build a short fixed row with ListView
Pass a small set of known widgets through children, in the order they should appear.
SizedBox(
height: 120,
child: ListView(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 12),
children: const <Widget>[
SizedBox(width: 160, child: Card(child: Center(child: Text('Books')))),
SizedBox(width: 160, child: Card(child: Center(child: Text('Music')))),
SizedBox(width: 160, child: Card(child: Center(child: Text('Games')))),
],
),
)
The width on each SizedBox sets where the next card begins. ListView children can be labels, images or custom widgets.
That fixed-child constructor keeps a short row explicit in the widget tree.
Padding controls outer insets. Reserve separators for spacing or dividers repeated between cards.
Step 4: Build data-backed items with ListView.builder
For data-backed items, ListView.builder calls itemBuilder for the requested index. Set itemCount to the collection length.
SizedBox(
height: 120,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (BuildContext context, int index) {
return SizedBox(
width: 160,
child: Card(child: Center(child: Text(categories[index]))),
);
},
),
)
The callback uses the requested index to select a value.
Here, each index selects a label from categories. If the source list changes, rebuild the widget with the updated count and values.
A prototypeItem can supply a representative child when the cards share an extent.
Step 5: Add spacing with ListView.separated
ListView.separated accepts a callback that provides the widget between adjacent items.
SizedBox(
height: 120,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (BuildContext context, int index) {
return SizedBox(
width: 160,
child: Card(child: Center(child: Text(categories[index]))),
);
},
separatorBuilder: (BuildContext context, int index) {
return const SizedBox(width: 12);
},
),
)
For a visible divider, return a narrow Container with a color instead of SizedBox. Set its width to the desired horizontal spacing.
Keep the separator visually subordinate to the cards. If a card already includes a border or internal margin, an extra separator may make the row look crowded. Decide whether the spacing belongs inside each card or between cards, then use one consistent method so the first and last items align with the surrounding page.
The callback supplies separators between neighboring items. It does not add one after the final item. Put any one-sided inset in the item itself.
Fix common horizontal ListView layout problems
Check the parent constraints first. Then review item dimensions and test gesture behavior when another scrollable shares the screen.
| Symptom | Likely cause | What to change |
|---|---|---|
| Viewport has unbounded height | The horizontal list has no finite cross-axis extent | Wrap it in SizedBox(height: …) or a parent with a bounded height |
| Cards stretch or have inconsistent widths | Items have no deliberate horizontal extent | Give each item a width, or use itemExtent when every item shares one size |
| Empty row shows a blank area | The data collection has no items | Conditionally show an empty-state widget before building the ListView |
| Nested lists compete for dragging | More than one scrollable can handle the same gesture | Bound each viewport and test the intended direction on the target device |
For an unbounded-height exception, inspect the immediate parent and give the viewport a finite vertical extent. The table maps that symptom to a practical adjustment.
When the data collection is empty, show an empty-state widget rather than constructing a row with no visible content. For service-backed data, give loading and failure their own screen states too.
A vertical page can contain a horizontal category row when each viewport has dimensions suited to its direction.
Different scroll directions give the page and row distinct drag tasks. When two scrollables share a direction, test their gesture behavior and remove a redundant one if it adds no reader task.
Touch dragging follows platform scroll behavior. Flutter’s horizontal-list cookbook shows a ScrollConfiguration that expands dragDevices when an app must support extra pointer types, such as a mouse. Apply that configuration only when the interaction requirement calls for it.
Use Flutter TabBar when the row represents selectable pages. For backend data, see fetching REST API data in Flutter.
Choose item sizing and scroll behavior
Item dimensions set the space each card occupies, while scroll physics affects motion at the ends of the row.
For category tiles, I would use a shared extent because equal widths make scanning the row predictable. Longer labels can justify per-item widths.
- Give variable cards their own widths.
- Use itemExtent for a uniform row.
- Set ListView padding for outer insets.
- Use separatorBuilder for spacers between neighbors.
Padding adds space at the row edges, while separators appear only between neighboring items.
For a small screen, decide whether a card should show part of the next item. A partial next card signals that the row continues. Full-width cards can hide that cue, so an edge inset or a narrower fixed item width can make the scrolling affordance visible.
Scroll physics determine how the list behaves at its ends and during a fling. Flutter’s default behavior follows the platform. A custom ScrollPhysics can alter that interaction, but should match a deliberate product requirement rather than compensate for incorrect constraints.
On desktop and web, pointer types can have different drag behavior. The horizontal-list cookbook demonstrates adding devices to ScrollConfiguration when a mouse drag should move the row.
Keyboard navigation and accessibility semantics also matter when users cannot drag directly. Give each card a useful semantic label when its visual text does not explain the action, and expose a selected category to assistive technology.
For a row of selectable categories, make the selected state visible rather than relying on position alone. A clear label and selected indication help users understand both what a card does and which choice is active. If cards navigate somewhere, use an interaction widget with appropriate semantics instead of making a decorative Container respond to taps without an accessible action.
Handle data changes and item identity
When a filter changes the collection, rebuild from the filtered data and reset or preserve the scroll position intentionally.
For asynchronously loaded data, keep the loading, failure, empty and populated states distinct. Build the horizontal row only for the populated state.
A loading indicator should occupy a layout region that makes sense before the items arrive. On failure, offer a retry or an error message rather than leaving a blank strip that looks like a successful empty result. Once data arrives, the same bounded row can render its cards.
if (categories.isEmpty) {
return const Center(child: Text('No categories available'));
}
return SizedBox(
height: 120,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: categories.length,
itemBuilder: (context, index) => CategoryCard(categories[index]),
),
);
This branch gives an empty collection its own screen state.
When items can be inserted, removed or reordered, use a key based on a stable model identifier so Flutter can preserve each element’s identity across position changes.
For a filtered collection, derive the displayed list before building the row. This keeps itemCount and index lookup tied to the same values.
Using the original count with a filtered lookup can make the final indexes refer to missing entries. Show an empty state when a filter produces no matches.
A builder callback should stay focused on creating one item from its index. Move complex card layout into a widget when the callback becomes hard to scan.
Builder requests visible item widgets as needed, but it does not remove the cost of loading or storing the underlying data. Pagination is a separate data-layer decision.
Filtering may leave the current offset beyond the new content range, so reset or preserve the position intentionally according to the screen’s behavior.
Conclusion: choose the constructor that fits the data
Set Axis.horizontal for sideways movement and size the viewport and cards for their content. Pick children for a short fixed row, builder for collection-backed cards, or separated when each pair needs an intervening widget.
For more detail, see Flutter’s horizontal list cookbook, the ListView API, and its guide to long lists.
FAQ
These answers cover the direction and sizing choices for a Flutter horizontal row.
How do I make a ListView scroll horizontally in Flutter?
Set scrollDirection to Axis.horizontal on the ListView and give its parent a finite height.
Should I use ListView or ListView.builder?
Use children for a short fixed row and ListView.builder for items generated from data.
Why does a horizontal ListView need a height?
It scrolls along its width but still needs a finite vertical size from its parent.




