Skip to content
FlutterDocs

[Solved] RenderBox was not laid out Error in Flutter

Verified Solution Tested on Flutter 3.47.7 • Dart 3.13.5
Jump to Updated Flutter Example ↓

In this post, we are going to show you how to solve “RenderBox was not laid out” error in Flutter. This error usually happened while rendering the widget in Flutter App.

Error Message:

Another exception was thrown: RenderBox was not laid out: 
_RenderDecoration#a09f6 relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderPointerListener#6dc15 relayoutBoundary=up7 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderSemanticsAnnotations#fa014 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderIgnorePointer#92b89 relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderMouseRegion#16447 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
_RenderFocusTrapArea#701fe relayoutBoundary=up3 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderFlex#accec relayoutBoundary=up2 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE

Another exception was thrown: RenderBox was not laid out: 
RenderRepaintBoundary#84f46 NEEDS-LAYOUT NEEDS-

Cause of Error:

This error usually happens due to the following errors while rendering the widget in Flutter:

Open the link to see the solution of each error:

Solution of Error:

If the error occurs due to the ListView(), then use List view like below:

ListView(
  shrinkWrap: true,
  children: [
        
  ],
)
Expanded(
  child:ListView(
      children: [
          
      ],
  ),
)

If the error is caused by TextField() or TextFormField() inside Row() widget, then wrap your TextField() like below:

Row(
  children: [
    Expanded(
      child:TextField()
    )
  ],
)

In this way, you can solve “RenderBox was not laid out” error in Flutter app. Layout rendering errors often coincide with unbounded dimensions; review the RenderFlex overflowed by pixels error and the Incorrect use of ParentDataWidget error.

Updated Flutter Example
SDK: Flutter 3.47.7 • Dart 3.13.5 Verified on Flutter 3.47.7 (Stable)

Updated Flutter Example

Resolving 'RenderBox was not laid out' with Explicit Constraints

Key Implementation Details & Modern Differences:

  • Layout Constraint Contract: In Flutter, 'Constraints go down. Sizes go up. Parent sets position.' A RenderBox throws this error if accessed before receiving valid constraints during layout.
  • LayoutBuilder Architecture: Uses LayoutBuilder to inspect incoming BoxConstraints and adapt child sizing dynamically to available screen real estate.
  • Flexible Child Wrappers: Employs Flexible with fit: FlexFit.loose to prevent unbounded text children from pushing siblings outside container boundaries.
Updated Flutter Example Code
import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: ModernRenderBoxConstraintsDemo()));
}

class ModernRenderBoxConstraintsDemo extends StatelessWidget {
  const ModernRenderBoxConstraintsDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('RenderBox Constraints Architecture')),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text(
              'Explicit Layout Constraints Demo',
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 12),
            // Pattern: LayoutBuilder ensures explicit, bounded parent constraints
            LayoutBuilder(
              builder: (context, constraints) {
                return Container(
                  width: constraints.maxWidth,
                  padding: const EdgeInsets.all(16.0),
                  decoration: BoxDecoration(
                    color: Theme.of(context)
                        .colorScheme
                        .surfaceContainerHighest,
                    borderRadius: BorderRadius.circular(8),
                  ),
                  child: Row(
                    children: [
                      const Icon(Icons.check_box_outlined),
                      const SizedBox(width: 8),
                      // Flexible prevents unconstrained child layout overflow
                      Flexible(
                        child: Text(
                          'Bounded width: ${constraints.maxWidth.toInt()}px layout pass completed safely.',
                        ),
                      ),
                    ],
                  ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
Document History & Archival Record

Original reference snapshot archived March 22, 2023. Updated working solution verified on modern Flutter & Dart SDKs.