resolve static method

EdgeInsets resolve(
  1. BuildContext context,
  2. TwStyle style, {
  3. required int? getUniform(
    1. TwStyle
    ),
  4. required int? getX(
    1. TwStyle
    ),
  5. required int? getY(
    1. TwStyle
    ),
  6. required int? getLeft(
    1. TwStyle
    ),
  7. required int? getRight(
    1. TwStyle
    ),
  8. required int? getTop(
    1. TwStyle
    ),
  9. required int? getBottom(
    1. TwStyle
    ),
})

Resolves spacing from TwStyle and TwConfig into EdgeInsets

Implementation

static EdgeInsets resolve(BuildContext context, TwStyle style, {
  required int? Function(TwStyle) getUniform,
  required int? Function(TwStyle) getX,
  required int? Function(TwStyle) getY,
  required int? Function(TwStyle) getLeft,
  required int? Function(TwStyle) getRight,
  required int? Function(TwStyle) getTop,
  required int? Function(TwStyle) getBottom,
}) {
  final config = TwConfig.of(context);
  final spacing = config.spacing;

  // Calculate spacing values
  double left = 0;
  double right = 0;
  double top = 0;
  double bottom = 0;

  // Apply uniform spacing
  final uniformValue = getUniform(style);
  if (uniformValue != null) {
    final value = _getSpacingValue(spacing, uniformValue, 'uniform');
    left = right = top = bottom = value;
  }

  // Apply directional spacing (these override uniform spacing)
  final xValue = getX(style);
  if (xValue != null) {
    final value = _getSpacingValue(spacing, xValue, 'horizontal');
    left = right = value;
  }
  final yValue = getY(style);
  if (yValue != null) {
    final value = _getSpacingValue(spacing, yValue, 'vertical');
    top = bottom = value;
  }
  final leftValue = getLeft(style);
  if (leftValue != null) {
    left = _getSpacingValue(spacing, leftValue, 'left');
  }
  final rightValue = getRight(style);
  if (rightValue != null) {
    right = _getSpacingValue(spacing, rightValue, 'right');
  }
  final topValue = getTop(style);
  if (topValue != null) {
    top = _getSpacingValue(spacing, topValue, 'top');
  }
  final bottomValue = getBottom(style);
  if (bottomValue != null) {
    bottom = _getSpacingValue(spacing, bottomValue, 'bottom');
  }

  return EdgeInsets.only(
    left: left,
    right: right,
    top: top,
    bottom: bottom,
  );
}