constraints property

BoxConstraints? constraints
final

Additional constraints to apply to the child.

RESTORED PARAMETER - This parameter was temporarily removed but has been restored because constraints are essential for terminal UI layout:

Why constraints exist in terminals:

  • BoxConstraints is a Dart-side layout abstraction, NOT an OpenTUI feature
  • Controls min/max sizing independently of fixed width/height values
  • Essential for flexible layouts in the constraint-based layout system
  • Flows layout information down the widget tree from terminal dimensions

Precise control beyond width/height:

  • width/height create tight constraints (min=max=value)
  • constraints allows independent min/max (e.g., minWidth: 10, maxWidth: 100)
  • Enables responsive layouts that adapt to available terminal space
  • Critical for proper layout composition with other constraint widgets

Precedence rules: If both constraints and width/height are provided, width/height take precedence by tightening the constraints to exact values. This matches Flutter behavior.

Terminal-specific considerations: All constraint values are rounded to whole character cells since terminals use a fixed character grid. Fractional constraints are clamped to integers.

Implementation

final BoxConstraints? constraints;