📱 Flutter Intermediate

What is LayoutBuilder in Flutter?

Answer

LayoutBuilder provides access to the parent widget's constraints inside the build method, enabling truly responsive layouts. Its builder function receives a BoxConstraints object with maxWidth and maxHeight, letting you make layout decisions based on the available space. For example, show a two-column layout when maxWidth > 600, otherwise single-column. This is more reliable than using MediaQuery for nested layouts because it reflects the actual available space, not the full screen size.