LayoutBuilder
Builds its child from the constraints it actually receives, so layout can adapt to the available space — a sidebar that collapses below a width, a list that switches to a grid when wide, etc.
Learn more: Layout
Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.
LayoutBuilder( builder: (context, constraints) => (constraints.maxCols ?? 0) > 60 ? Wide() : Narrow(),)Details
Section titled “Details”The builder runs during layout rather than build. It runs again when the
incoming constraints change, when the parent rebuilds this widget, or when
something the builder reads changes, such as a scope like
MediaQuery.of(context) or an animation’s value; otherwise the child it
built last time is kept, so the builder doesn’t run on every frame. An
exception in the builder is handled like one thrown by a build method: the
error widget takes the child’s place.
An axis can be unbounded: constraints.maxCols or maxRows is null for an
inflexible child of a Row or Column, for example. A builder that sizes
from that axis needs a bound, so wrap this widget in Expanded or
SizedBox. With assertions enabled, a child that comes out zero-sized on
an unbounded axis while non-empty on the other throws a StateError that
says so.
Constructors
Section titled “Constructors”LayoutBuilder()
Section titled “LayoutBuilder()”| Parameter | Type | Default | Description |
|---|---|---|---|
builder: | LayoutWidgetBuilder | required | Creates the child for the constraints received during the current layout. |
Source
Section titled “Source”LayoutBuilder is defined in packages/fleury/lib/src/widgets/layout_builder.dart.
Category: Layout · All widgets