build static method

Widget build(
  1. BuildContext context,
  2. Widget? child,
  3. FlyStyle flyStyle,
  4. Key? key,
  5. AlignmentGeometry? alignment,
  6. EdgeInsetsGeometry? padding,
  7. EdgeInsetsGeometry? margin,
  8. Decoration? decoration,
  9. Decoration? foregroundDecoration,
  10. double? width,
  11. double? height,
  12. BoxConstraints? constraints,
  13. Matrix4? transform,
  14. AlignmentGeometry? transformAlignment,
  15. Clip? clipBehavior,
)

Build container (with or without child)

Implementation

static Widget build(
  BuildContext context,
  Widget? child,
  FlyStyle flyStyle,
  Key? key,
  AlignmentGeometry? alignment,
  EdgeInsetsGeometry? padding,
  EdgeInsetsGeometry? margin,
  Decoration? decoration,
  Decoration? foregroundDecoration,
  double? width,
  double? height,
  BoxConstraints? constraints,
  Matrix4? transform,
  AlignmentGeometry? transformAlignment,
  Clip? clipBehavior,
) {
  // Resolve alignment - prioritize explicit alignment, then layout utilities
  final resolvedAlignment = child != null
      ? (alignment ?? BoxAlignment.resolveFromLayoutUtilities(flyStyle))
      : alignment;
  final resolvedPadding =
      padding ?? BoxProperty.resolvePadding(context, flyStyle);
  final resolvedMargin =
      margin ?? BoxProperty.resolveMargin(context, flyStyle);
  final resolvedDecoration =
      decoration ?? BoxProperty.resolveDecoration(context, flyStyle);
  final resolvedForegroundDecoration = foregroundDecoration;
  final resolvedWidth = width ?? BoxProperty.resolveWidth(context, flyStyle);
  final resolvedHeight =
      height ?? BoxProperty.resolveHeight(context, flyStyle);
  final resolvedConstraints = constraints;
  final resolvedTransform = transform;
  final resolvedTransformAlignment = transformAlignment;
  final resolvedClipBehavior = clipBehavior ?? Clip.none;

  // Handle custom borders (dashed/dotted) with special logic
  if (flyStyle.hasBorder && FlyBorderUtils.needsCustomBorder(flyStyle)) {
    return BoxBorderBuilder.buildCustomBorder(
      context,
      child ?? const SizedBox.shrink(), // Fallback for null child
      flyStyle,
      resolvedAlignment,
      resolvedPadding,
      resolvedMargin,
      resolvedForegroundDecoration,
      resolvedWidth,
      resolvedHeight,
      resolvedConstraints,
      resolvedTransform,
      resolvedTransformAlignment,
      resolvedClipBehavior,
    );
  }

  // Create Container with resolved properties for solid borders
  Widget containerWidget = Container(
    key: key,
    alignment: resolvedAlignment,
    padding: resolvedPadding,
    margin: resolvedMargin,
    decoration: resolvedDecoration,
    foregroundDecoration: resolvedForegroundDecoration,
    width: resolvedWidth,
    height: resolvedHeight,
    constraints: resolvedConstraints,
    transform: resolvedTransform,
    transformAlignment: resolvedTransformAlignment,
    clipBehavior: resolvedClipBehavior,
    child: child,
  );

  // Apply intrinsic width constraints if needed
  return FlySizeUtils.apply(context, flyStyle, containerWidget);
}