apply static method

Widget apply(
  1. BuildContext context,
  2. FlyStyle style,
  3. Widget child
)

Applies size constraints to a widget using the resolved values

Implementation

static Widget apply(BuildContext context, FlyStyle style, Widget child) {
  final height = resolveHeight(context, style);
  final width = resolveWidth(context, style);
  final intrinsicWidth = resolveIntrinsicWidth(style);
  final maxHeight = resolveMaxHeight(context, style);
  final maxWidth = resolveMaxWidth(context, style);
  final minHeight = resolveMinHeight(context, style);
  final minWidth = resolveMinWidth(context, style);

  // If no size constraints are set, return the child as-is
  if (height == null &&
      width == null &&
      intrinsicWidth == null &&
      maxHeight == null &&
      maxWidth == null &&
      minHeight == null &&
      minWidth == null) {
    return child;
  }

  // Handle intrinsic width constraints
  if (intrinsicWidth != null) {
    return _applyIntrinsicWidth(
      child,
      intrinsicWidth,
      height,
      maxHeight,
      maxWidth,
      minHeight,
      minWidth,
    );
  }

  // If we have max/min constraints, use ConstrainedBox
  if (maxHeight != null ||
      maxWidth != null ||
      minHeight != null ||
      minWidth != null) {
    return ConstrainedBox(
      constraints: BoxConstraints(
        minWidth: minWidth ?? 0,
        maxWidth: maxWidth ?? double.infinity,
        minHeight: minHeight ?? 0,
        maxHeight: maxHeight ?? double.infinity,
      ),
      child: SizedBox(height: height, width: width, child: child),
    );
  }

  // If only fixed size constraints, use SizedBox
  return SizedBox(height: height, width: width, child: child);
}