Back to Blog
Bug Fixes•1 min read

Fix Flutter 'Vertical viewport was given unbounded height'

Scaleup Infotech Team
Scaleup Infotech Team

Custom Software & Business Automation

FlutterLayoutListView

In this guide

A simple guide to this issue: Flutter 'Vertical viewport was given unbounded height'. Learn why it happens, what to check first, and how to fix it.

Putting a scrollable ListView directly inside a Column confuses Flutter: the Column offers infinite height, but the ListView needs a bounded height to know how big to be. You have to constrain it.

The Error

Vertical viewport was given unbounded height. RenderBox was not laid out.

Fix 1: Wrap the ListView in Expanded

dart
Column(
  children: [
    const Header(),
    Expanded(           // gives the ListView a bounded height
      child: ListView(children: items),
    ),
  ],
)

Fix 2: shrinkWrap for a Short, Non-Scrolling List

dart
ListView(
  shrinkWrap: true,
  physics: const NeverScrollableScrollPhysics(),
  children: items, // sizes to content; let the parent scroll
)

Don't shrinkWrap Big Lists

shrinkWrap measures every child up front — fine for 5 items, terrible for 5,000. For long lists, use Expanded or a CustomScrollView with slivers.

Relevant Scaleup Infotech Services

Share this article:

Keep Reading

Ready to implement these ideas?

Discuss Your Project