Why Flutter's LayoutBuilder Crashes Inside Table or IntrinsicHeight Widgets
Flutter's LayoutBuilder throws a runtime error when placed inside widgets that rely on intrinsic dimension queries, such as Table, IntrinsicHeight, or IntrinsicWidth. This happens because answering an intrinsic size query would require LayoutBuilder to speculatively run its builder callback, which could mutate the live render tree — something Flutter explicitly prohibits. Flutter's layout system is designed as a single downward pass where parents hand constraints to children, and the intrinsic protocol is a separate, read-only measurement path that LayoutBuilder cannot safely participate in. The error is intentional by design, not a bug, and surfaces only when a parent widget higher in the tree initiates an intrinsic measurement query. Developers can work around the limitation by measuring text imperatively using TextPainter, which operates outside the render tree and is safe to call during layout or build.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in