Skip to content

AspectRatio

Sizes its child to a target width:height ratio while staying within the parent’s constraints. When bounded constraints admit the ratio, the largest matching box wins. An unbounded axis falls back to its minimum, and incompatible minimums can force the result away from the target ratio.

Learn more: Layout

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

AspectRatio(
aspectRatio: 2.0,
child: Heatmap(values: values),
)

⚠ Terminal cells are typically taller than wide (often roughly 2:1 height:width). A literal 1:1 aspectRatio produces a visually rectangular box. For visually square content (e.g. heatmap cells) multiply by the cell height-to-width ratio: AspectRatio(aspectRatio: 2.0, ...) for a typical 2:1 cell, or use your terminal’s measured cell aspect.

ParameterTypeDefaultDescription
aspectRatio:doublerequiredTarget ratio expressed as width / height in cells. A ratio of 2.0 means the box is twice as wide as it is tall.
child:WidgetrequiredContent laid out within the resolved box.

AspectRatio is defined in packages/fleury/lib/src/widgets/basic.dart.

Category: Layout · All widgets