resolve static method

Border resolve(
  1. BuildContext context,
  2. FlyStyle style
)

Resolves border from FlyStyle and FlyTheme into Border

Implementation

static Border resolve(BuildContext context, FlyStyle style) {
  try {
    final spacing = FlyTheme.of(context).spacing;
    final colors = FlyTheme.of(context).colors;

    // Check if any border is set
    if (!_hasBorder(style)) return Border.all(width: 0);

    // Resolve border color
    final borderColor = _resolveBorderColor(style, context, colors);
    if (borderColor == null) return Border.all(width: 0);

    // Resolve border style
    final borderStyle = _resolveBorderStyle(style);

    // Resolve individual border sides
    final topWidth = _resolveBorderSideWidth(
      style.borderT ?? style.border,
      context,
      spacing,
    );
    final rightWidth = _resolveBorderSideWidth(
      style.borderR ?? style.border,
      context,
      spacing,
    );
    final bottomWidth = _resolveBorderSideWidth(
      style.borderB ?? style.border,
      context,
      spacing,
    );
    final leftWidth = _resolveBorderSideWidth(
      style.borderL ?? style.border,
      context,
      spacing,
    );

    return Border(
      top: topWidth > 0
          ? BorderSide(
              width: topWidth,
              color: borderColor,
              style: borderStyle,
            )
          : BorderSide.none,
      right: rightWidth > 0
          ? BorderSide(
              width: rightWidth,
              color: borderColor,
              style: borderStyle,
            )
          : BorderSide.none,
      bottom: bottomWidth > 0
          ? BorderSide(
              width: bottomWidth,
              color: borderColor,
              style: borderStyle,
            )
          : BorderSide.none,
      left: leftWidth > 0
          ? BorderSide(
              width: leftWidth,
              color: borderColor,
              style: borderStyle,
            )
          : BorderSide.none,
    );
  } catch (e) {
    throw ArgumentError('Failed to resolve border: $e');
  }
}